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
subramanya.vl
0
Junior Poster in Training
Recommended Answers
Jump to PostAn 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
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.