• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

immutable???

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just heard the word somewhere.
In reference of the string class.
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Immutable means that the object value can not be changed.

It has no mutator methods, which in Java traditionally starts with set.

Any methods in the String class that alter the current String, returns a reference to a new String. It seems wasteful to me to have all that overhead, but if your program needs to make a lot of changes StringBuffer is mutable.

I am not sure why they decided on this, but they were determined to keep it immutable so they made the class final as well.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rusty Shackleford wrote:It has no mutator methods, which in Java traditionally starts with 'get'.


You mean 'set'. Methods that start with 'get' (accessor methods) are quite frequently used with immutable objects.
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, set. Thank you.

There needs to be a no posting before caffeine rule.
 
reply
    Bookmark Topic Watch Topic
  • New Topic