You are correct. All should be eligible for GC. But not because they are distinct but because they are created dynamically at runtime. Doing " Hello "+i does not allow compiler to assume them as
string literals because i is a variable. If it were something like " hello" +" world", it would become a new string literal " hello world" at compile time and would not GCed.
HTH,
Paul.
------------------
SCJP2 Resources, Free Question A Day, Mock Exam Results and More!
www.jdiscuss.com Get Certified, Guaranteed!
www.enthuware.com/jqplus
Your guide to
SCJD exam!
www.enthuware.com/jdevplus [This message has been edited by Paul Anil (edited August 08, 2001).]