File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes How to create immutable classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to create immutable classes" Watch "How to create immutable classes" New topic

How to create immutable classes

manish basotia
Ranch Hand

Joined: Jan 12, 2004
Posts: 47
Please reply fast
Erik Pragt
Ranch Hand

Joined: Sep 08, 2001
Posts: 125

Very easy
Scotty Sinclair

Joined: Jun 26, 2003
Posts: 17
Just to clarify, A class is immutable a long as no method calls will change the state of the class. So the above example is fine.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Check the javaRanch Journal: Mutable and Immutable Objects
John O'Hanley

Joined: Oct 13, 2002
Posts: 24
Here is some good info on immutable object:
It is sorta covered in the JavaRanch Style Guide.
subject: How to create immutable classes