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-
String s="abc";
s=s.concat("def");
now object "abc" can not be referenced at all but as strings are immutable it will still exist in the memory pool.