public static void main(String[] args) {
String s1="me";
String s2="me".toUpperCase().toLowerCase();
System.out.println(s1==s2);
/*The line above prints false as output*/
}
String is immutable it means that if a string is created as "me" a object will be created and location will be assigned to variable and if another String is created with same data i.e. "me" instead of creating another object the JVM refers to the same location of first string. In given code "me" and "me" are created but have different location! I think both s1 and s2 should refer to same location as the final data stored is same case wise.
Please help me by telling me that why JVM is creating 2 objects even both have the same data.