class test { public static void main(String args[]) { String x1 = "abc"; String x2 = "ab"; x2 = x2 + "c"; System.out.println(x1==x2);
} } why does it print false? in this case 3 objects will be formed in the string pool and they will be ("abc"),("ab").("c")and both the refrences x1,x2 will point to ("abc") i concluded this from -> To make Java more memory efficient, the JVM sets aside a special area of memory called the “String constant pool.” When the compiler encounters a String literal, it checks the pool to see if an identical String already exists. If a match is found, the reference to the new literal is directed to the existing String, and no new String literal object is created. Please tell me whats the flaw in what i am thinking Thanks&Regards --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~----------~----~----~----~------~----~------~--~---