jeudi 2 avril 2015

on concating two String s1 and s2,produced output String s3 will create in heap or constant pool in java?


String S1="He";

String S2="llow";

String S3="Hellow";

String S4="He"+"llow";

String S5=S1+S2;

System.out.println(S3==S4);
System.out.println(S5==S3);
System.out.println(S5==S4);


why S5 is not referring object from constant pool? since S3 and S4 are in pool thats why giving true on S3==S4 but in case of S5==S3 & S5==S4 result is false,means S5 is not in pool.


Aucun commentaire:

Enregistrer un commentaire