top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Java: How the string objects in string constant pool garbage collected?

0 votes
63 views
Java: How the string objects in string constant pool garbage collected?
posted Mar 14, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

String a = new String("asd") -> "a" reference will be garbage collected, but is just a reference to "asd" and "asd" will be there forever.

answer Mar 16, 2016 by Shubham Singh
Similar Questions
0 votes

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?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...