For the below code:
String bis = "good";
String cis ="good";
char[] ch = {'g','o','o','d'};
String temp="";
for (char c:ch){
temp=temp+c;
}
System.out.println(temp);
System.out.println(cis==bis); //true
System.out.println(bis==temp); //false
'temp' variable evaluates to "good" same as 'bis' and 'cis' but bis==temp returns false unlike bis==cis which evaluates to true.Please let me know why this happens? In String pool "good" object is there.So 'temp' reference should ideally be pointing to it right as done by bis and cis?