• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion about string objects

 
Roger Fed
Ranch Hand
Posts: 82
Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain the meaning that string objects is immutable?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically it means that once you created a String, you can't change it (one of its characters for example).
Any operation like swapping a character, upper casing it and others is going to create a new String.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that you can't change the String object, but changing the String reference is possible (if the variable isn't final):
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roger, you can see the source code of String API methods to research more on this topic....

It will give you more knowledge and confidence on this popular question...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic