Hi Maha Anna
Thank you For sending above piece of code , which gives clear understanding of strings & POOL of Strings. I would be glad if you could clear my doubt about POOL of strings , to the given code I added to 2 more tests which I have listed below
if(deepaLowercaseStr.intern() == "deepa ".trim())System.out.println("Pass15");
else System.out.println("Pass15 failed"); //result is: Pass15 Failed
if(deepaLowercaseStr.intern() == "deepa".trim()) System.out.println("Pass16");
else System.out.println("Pass16 failed"); // result is: Pass16
by this can we say that Strings are added to the
string pool only if created by " " this way ( i.e.using Double Quotes ) or by calling intern method on string Objects. All other strings objects returned from methods or String Objects constructed using new operator are not added to the POOL