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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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
I agree. Here's the link:
subject: Creating new Strings
It's not a secret anymore!