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 Exception {
  11. int [] array1 = new int[]{1,2,3};
  12. int [] array2 = new int[]{1,2,3};
  13. int [] array3 = new int[]{1,2,3};
  14.  
  15. System.out.println(array1 == array2);//this will print false
  16. System.out.println(Arrays.equals(array1, array2));//this will print true
  17. array2 = array1;
  18. //now "==" will return true
  19. System.out.println(array1 == array2);
  20. Arrays.sort(array1);
  21. Arrays.sort(array3);
  22. System.out.println(Arrays.equals(array1,array3));
  23.  
  24.  
  25.  
  26. }
  27. }
  28.  
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
false
true
true
true