title: Are objects in string constant pool eligible for garbage collection?
body: <p>How many objects will be eligible for garbage collection after completion of  compute method?</p>
  
  <p>I have searched this question and everywhere the answer is 1.    </p>
  
  <pre><code>public void compute(Object p)
  
      {
  
       Object a = new Object();
  
       int x = 100;
  
       String str = "abc";
  
      }
  </code></pre>
  
  <p>But as far as I know, the string constant pool is a part of the heap now in Java 7 and eligible for garbage collection.</p>
  
  <p>According to me, 2 objects are eligible for garbage collection i.e  <code>a</code> and <code>str</code>.</p>