Java Immutable Classes

Immutable means that the state of an Object cannot be changed once it initialized that is you can’t change any of the attributes, to change it you have to create a new Object itself.

Here is the list of java classes which are immutable.

  1. java.lang.String
  2. java.lang.Boolean
  3. java.lang.Byte
  4. java.lang.Double
  5. java.lang.Integer
  6. java.lang.Float
  7. java.lang.Long
  8. java.lang.Character

Usually Immutable classes don’t have setter methods and are final.

0 comments… add one

Leave a Comment