title: Java String Pool changing the reference of object
body: <p>i create a string object using assignment operator </p>
  
  <blockquote>
    <p>String nameVar = "Henry";
    <br>
    (Which makes a object in String pool/Constant pool with value of Henry)</p>
  </blockquote>
  
  <p>Then i assign again a new value to variable <b>nameVar</b>.</p>
  
  <blockquote>
    <p>nameVar = "Ann";<br>
    (Which makes a object in String/Constant pool with value "Ann" and new reference address is stored in variable)</p>
  </blockquote>
  
  <p>My problems..<br>
  1.Problem  is after assigning second object to variable does previous object is discarded or store in pool?</p>
  
  <p>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?;</p>
  
  <blockquote>
    <p>String newNameVar = "Henry";</p>
  </blockquote>
  
  <p>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?</p>
  
  <blockquote>
    <p>String oldVar = new String("Britney");<br>
    String newVar = new String("Britney");</p>
  </blockquote>
  
  <p>cheers.</p>