A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
Java in General
Joined: Jun 15, 2006
Jan 02, 2007 02:57:00
how can make a class Immutable?
author and iconoclast
Joined: Jul 08, 2003
Jan 02, 2007 05:38:00
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]
subject: class Immutable
Math class immutable
Is the Math class considered immutable?
equals() and ==
How to make a class immutable??????????
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014