There are mainly 2 ways of creating String
objects:
String s =
"GetSure" : One String object will create in String
constant pool and S is referring to that object.
String s = new
String("GetSure") : One String object is created on the heap
and s is pointing to that object.Now JVM will check is there any object present
in the constant pool with this content, if there is no such object JVM will
keep another object in the String constant pool with this content. This object
is reserved for future purpose.
No comments:
Post a Comment