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 and Immutability 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
Bookmark "String and Immutability" Watch "String and Immutability" New topic

String and Immutability

Gourav Prat

Joined: Jul 12, 2005
Posts: 9
By using Replace method of String we can change a string content.
But string is immutable.So how this thing can be explained?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You are creating a new String object by using any method which might suggest a String was anything other than immutable (such as replace()).

(By the way - this might have been better posted in the Java In General (Beginners) forum, since it doesn't really have anything to do with performance).
[ July 12, 2005: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

Moving to Java in General (Beginner).

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: String and Immutability
It's not a secret anymore!