File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
I agree. Here's the link:
subject: Creating new Strings
jQuery in Action, 3rd edition