fork(12) 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. String mango = "mango";
  13. String mango2 = "mango";
  14. String mango3 = new String("mango");
  15. System.out.println(mango != mango2);
  16. System.out.println(mango == mango2);
  17. System.out.println(mango3 != mango2);
  18. System.out.println(mango3 == mango2);
  19. // mango2 = "mang";
  20. System.out.println(mango+" "+ mango2);
  21. System.out.println(mango != mango2);
  22. System.out.println(mango == mango2);
  23.  
  24. System.out.println(System.identityHashCode(mango));
  25. System.out.println(System.identityHashCode(mango2));
  26. System.out.println(System.identityHashCode(mango3));
  27.  
  28. }
  29. }
Success #stdin #stdout 0.11s 321600KB
stdin
Standard input is empty
stdout
false
true
true
false
mango mango
false
true
17225372
17225372
5433634