Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Ron McLeod
Liutauras Vilda
Paul Clapham
paul wheaton
Sheriffs:
Tim Cooke
Devaka Cooray
Rob Spoor
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Forum:
Java in General
class Immutable
sreejith panampilly
Ranch Hand
Posts: 49
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
how can make a class Immutable?
Ernest Friedman-Hill
author and iconoclast
Posts: 24204
44
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Very simply, don't provide any way to modify any of the member variables. It's that simple. Make sure they're all private, and preferably final, and don't change them after the constructor.
[Jess in Action]
[AskingGoodQuestions]
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Math class immutable
Is the Math class considered immutable?
Java
equals() and ==
How to make a class immutable??????????
More...