This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Creating new Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating new Strings" Watch "Creating new Strings" New topic

Creating new Strings

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
String s ="abc" // Creates one String object and one reference variable. How ?

String s = new String("abc") // Creates two objects, and one reference variable. How ?

Can someone please explain the above two comments.
Pushkar Choudhary

Joined: May 21, 2006
Posts: 425

This question has been asked many times. Please SearchFirst.

A couple of threads discussing the same here and here.
Yogesh Gnanapraksam
Ranch Hand

Joined: Dec 17, 2009
Posts: 133
Also this thread could be useful
Don't get me started about those stupid light bulbs.
subject: Creating new Strings