i create a string object using assignment operator
String nameVar = "Henry";
(Which makes a object in String pool/Constant pool with value of Henry)
Then i assign again a new value to variable nameVar.
nameVar = "Ann";
(Which makes a object in String/Constant pool with value "Ann" and new reference address is stored in variable)
My problems..
1.Problem is after assigning second object to variable does previous object is discarded or store in pool?
2.if it is stored in pool. i create a another new variable and create a string object with value "Henry" using assignment operator does it refer to same object that stored in pool?;
String newNameVar = "Henry";
3.i create a String object using new operator with a value "Britney" then i create another string variable(Object) using new operator with same value "Britney". does second variable refer to previous object or just create a new object and refer to it?
String oldVar = new String("Britney");
String newVar = new String("Britney");
cheers.