wood burning stoves 2.0*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String and Immutability" Watch "String and Immutability" New topic
Author

String and Immutability

Gourav Prat
Greenhorn

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
Bartender

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Moving to Java in General (Beginner).


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String and Immutability