I know this seems to be a very basic questions but still want to clear my basic knowledge so i am asking this question What is String Pool in java?
what is difference between
String var="DANIWEB;
and
String var =new String("DANIWEB");
jamesr12 0 Newbie Poster
Recommended Answers
Jump to PostString var = "daniweb"; String val = "daniweb";
the above will only place one String in the pool, and the other String will point to that one as well.
String var = "daniweb"; String val = new String("daniweb");
since you here are explicitly saying …
Jump to Postsince you here are explicitly saying you want a new Object, a new String will be created in the pool, and your second variable will point to that one
This isn't correct AFAIK; instantiating new strings on demand doesn't send them to the "string pool" unless the newly …
All 8 Replies
stultuske 1,116 Posting Maven Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
stultuske 1,116 Posting Maven Featured Poster
jamesr12 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
jamesr12 0 Newbie Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
jamesr12 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.