I know that Strings are immutable. But I have a doubt in below code:
class StringTest {
String s1 = "Joe";
String s2 = "Joe";
System.out.println(s1 == s2);
}
== checks whether both are referred to same memory address or not (if I am not wrong). If so, even the two strings are assigned to two different variables, why the output says both are referred to same memory address.