As I am studying java, I have learned that the proper way to compare 2 Strings is to use equals and not \"==\". This line
static String s1 = \"a\"; static String s2
String declared in Java code are automatically interned.
So the result is the same as you would call String.intern() manually.
String a = "aa";
String b = new String(a);
System.out.println("aa" == "aa");
System.out.println(a == b);
System.out.println(a.equals(b));
System.out.println(a.intern() == b.intern());
output:
true
false
true
true