top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Will the String literal be garbage Collected in Java?

0 votes
268 views

Will the String literal be garbage Collected?

  1. String str="ansh";
  2. str=null;
  3. //More code here

If no reference of String str is there after line 2, will this string become eligible for garbage collection or will it remains in String pool during the entire execution?

posted Sep 7, 2015 by Anamika

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

...