This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes String s = new String( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

String s = new String("abc"); //two objects??

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
K&B says that the above statement creates two objects and one reference variable.I can see clearly see one reference and one object.Where is the second object?

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44433
I think you have got the answer on your other thread, so I shall close this one.
Please avoid asking the same question twice.
I agree. Here's the link:
subject: String s = new String("abc"); //two objects??
It's not a secret anymore!