It is interesting and important to understand how strings are handled in Java. The way Java handles or manages strings is little different from other objects. Case1 : String a = "java"; String b= "java"; Does these two strings represent the same object reference ?. The answer is yes they do. Case 2: String c=new String("java"); String d =new String("java"); Does c and d point to the same object reference. The answer is NO . They don't. Now let us see how all these work out. First thing: Java maintains a pool of string constants called literal pool. Infact this pool contains references to string instances in heap. Since Strings are also objects they are also created in the heap. Whenever you put a literal ( example to this is what the variable a represents) in the code, this gets special treatment. When the JVM loads your class where there is a string literal, the VM checks whether there is an existing entry in the string pool for this string ...
On J2EE,Oracle,Hibernate and Progress