This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
The pool, with reference to String literals: Is this pool, created/maintained by JVM - on a per class basis? - on a package basis? or - for everything per JVM session In JLS, in the section "3.10.5 String Literals", the code example output proves that a string literal has a unique reference from anywhere - class, same/different class(s), same/different package(s). I guess, my question is : Can i have the string literal "Hello" in any 2 different places and prove that they are not equal. I am trying to compare and contrast the code example in the section "3.10.5 String Literals" of JLS. Thanks for any help Madan
check this code out: class StringTest{ public static void main(String s[]){ String a=" hello"; String b=" hello"; if (a.equals(b)) System.out.println(" Same contents"); else System.out.println(" Different contents"); if (a==b) System.out.println(" same object"); else System.out.println(" Different objects"); } i think this will solve ur problem since if u declare the string b in the above manner then it will be the same object that will be referred to.but if u declare b as String b=new Sring(" hello"); then u get different results.