fork(5) 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. // First initialization of array
  13. int[] array = new int[] { 1, 2, 3 };
  14.  
  15. // Prints "1 2 3 ".
  16. for (int i : array) {
  17. System.out.print(i + " ");
  18. }
  19.  
  20. // Re-initializes array to a new int[] array.
  21. array = new int[] { 4, 5, 6 };
  22.  
  23. // Prints "4 5 6 ".
  24. for (int i : array) {
  25. System.out.print(i + " ");
  26. }
  27.  
  28. // Uncomment to get compile-time error!
  29. //Can't re-initialize an array via shortcut
  30. // syntax with array initializer.
  31. //array = { 1, 2, 3, 4 };
  32. }
  33. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6