Skip to Main Content

Java Programming

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 and new String("')

807569May 16 2006 — edited May 16 2006
Hi Friends,
Hope you all are doing good!

String str1 = new String ("abc");
String str2 = "bcd";

The first one is an object and the second one a variable.

Is the second one a primitive one?

How is the storage for both cases handeled?

I mean is it right to say that first one is stored on HEAP since all objects are stored on HEAP.

While the second is stored on STACK (But i think this is wrong and a bit confusing)..

Would appreciate any replies from your side

Thanks,
Vishal
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 13 2006
Added on May 16 2006
5 comments
226 views