title: How Java manage memory efficiently
body: <p>Strings are immutable in java i.e. every time we make changes in string object it creates a new instance and the old object become unreferenced i.e. waste. so in a big program there will be so many unreferenced objects which can not be access. Does java manage this? how?
  for example- </p>
  
  <pre><code>String s="abc";
  s=s.concat("def");
  </code></pre>
  
  <p>now object "abc" can not be referenced at all but as strings are immutable it will still exist in the memory pool.</p>