I know that java.long.String is an immutable class.
I need to know different ways on to how create an immutable class in java.
What are the pros and cons of immutable class
Jump to Post
An immutable class cannot change any of its values after an instance has been created.
eg You can make all its variables private, and don't write any setter methods.
Immutable classes can be very efficient becuase the code can assume that no value ever changes. The "con" is that if …
All 2 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.