Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String and Immutability

 
Gourav Prat
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java in General (Beginner).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic