Hi Balaguru,
This is your code..
String one="one";
one="two";
System.out.println(one);
Lets rewrite it for better understanding...
String one; <-- String reference variable is created
one="one"; <-- "one" String Literal is created in
the pool and it is referenced by
one one="two"; <-- "two" String Literal is created in
the pool and it is now referenced
by
one System.out.println(one); <-- As currently
one points
to String Literal "two" ,it is
printed.
Hope this helps..
Jeban
Originally posted by Balaguru Janarthanan:
But who created object "two"? pls clarify?