fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3. String foo1 = "foo";
  4. String foo2 = "foo";
  5. System.out.println(foo1 == foo2); // may be true
  6.  
  7. String foo3 = new String("foo");
  8. String foo4 = new String("foo");
  9. System.out.println(foo3 == foo4); // always false
  10. }
  11. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
true
false