In the following code a string is created in pool and then it is concat creating there additional string object. The final is "2cfalse" and is referred by a. Then in line 7, because of Strings' non-repeating nature, I think it does not create separate literal as "2cfalse" so the == operator must return true .. Why its not returning true..
class demo {
public static void main(String aaa[]) {
String a = "";
a += 2;
a += 'c';
a += false;
if (a == "2cfalse")
System.out.println(1);
if (a.equals("2cfalse"))
System.out.println(2);
}
}