Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

String constant Pool

814889Dec 23 2011 — edited Dec 26 2011
HI ,

I have doubt about string constant pool , i want to understand it .As far as i know string maintains a pool where if a new string is created for the same string which is already created then new object will not be created instead it will point to same memory adddress.

String a = new String("aa");
String b ="aa";
String c="aa";

do all three references a,b,c all refer to same object?

and also if string are immutable then below code generated new stirng object or what does it do?
a=a+b;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 23 2012
Added on Dec 23 2011
4 comments
363 views