This question has already been answered:
- How to compare strings in java? 2 answers
Tell me, how does the compiler work in this case? Interested in how the reference of the object str1 compared with (str2+str3) ? str1 in this case is a reference to a String Object, and what is (str2+str3) ?
String str1 = "name"; String str2 = "name"; String str3 = ""; System.out.println(str1==(str2+str3) ? "true" : "false"); The result will be false