fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. // array1 having three null elements
  9. String[] array1 = new String[]{ "hello", "world", "from", "array1", null, null, null };
  10. // array2 having no null elements
  11. String[] array2 = new String[]{ "hi", "this", "is", "array2" };
  12.  
  13. // print array1
  14. for (String value : array1)
  15. {
  16. System.out.println(value);
  17. }
  18.  
  19. // swap values
  20. array1 = array2;
  21.  
  22. // print array1 again
  23. for (String value : array1)
  24. {
  25. System.out.println(value);
  26. }
  27. }
  28. }
Success #stdin #stdout 0.06s 380224KB
stdin
Standard input is empty
stdout
hello
world
from
array1
null
null
null
hi
this
is
array2