I know that "==" compare reference and the a java String is immutable and use a string pool cache but I'm still confusing on this example :
final String fName = "James";
String lName = "Gosling";
String name1 = fName + lName;
String name2 = fName + "Gosling";
String name3 = "James" + "Gosling";
System.out.println(name1 == name2); // 1
System.out.println(name2 == name3);
This gave me as results :
false
true
I still confused why System.out.println(name1 == name2); give me a false as I know the both values should be cached in the string pool ?