jQuery in Action, 2nd edition
The moose likes Beginning Java and the fly likes String and Immutability Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 24050
    
  13

Moving to Java in General (Beginner).


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String and Immutability
 
Similar Threads
trim()
instanceof
amount currency datatype
parsing a string an basis of a delimetre
GENERICS