About Question com.enthuware.ets.scjp.v6.2.426 :
Moderator: admin
- 
				ETS User
 
About Question com.enthuware.ets.scjp.v6.2.426 :
I understood that strings were put in the string pool and therefore not GC'd?
			
			
									
									
						- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question com.enthuware.ets.scjp.v6.2.426 :
Not all strings fall into that category. If you create a string using new e.g. new String("xyz"), there are actually two string objects created, one instantiated in a string pool (which cannot be GCed) and another one in the heap (which can be GCed).
HTH,
Paul.
			
			
									
									
						HTH,
Paul.
- 
				adrianoribeiro
 - Posts: 1
 - Joined: Fri Dec 21, 2012 9:51 pm
 - Contact:
 
Re: About Question com.enthuware.ets.scjp.v6.2.426 :
Hi, we should not consider the "" as collectible?
thanks.
			
			
									
									
						thanks.
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question com.enthuware.ets.scjp.v6.2.426 :
That depends on whether it is a literal or now.adrianoribeiro wrote:Hi, we should not consider the "" as collectible?
thanks.
String s = ""; //not collectible.
String s = new String(""); //collectible.
Who is online
Users browsing this forum: No registered users and 92 guests