fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // Instantiate an array for `Integer` objects, with each of its 3 elements being null.
  13. Object[] o2 = new Integer[3] ;
  14. System.out.println( Arrays.toString( o2 ) ) ;
  15.  
  16. o2[0] = new Integer( 7 ) ; // Assign an `Integer` object holding a `int` primitive within.
  17. o2[2] = 42 ; // Assign a primitive value where auto-boxing automatically wraps the `int` value in an `Integer` object, then places within the array.
  18. System.out.println( Arrays.toString( o2 ) ) ;
  19. }
  20. }
Success #stdin #stdout 0.08s 41016KB
stdin
Standard input is empty
stdout
[null, null, null]
[7, null, 42]