This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Immutable class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Immutable class" Watch "Immutable class" New topic

Immutable class

leela krishhna

Joined: Aug 24, 2012
Posts: 10
How to create simple User defined Immutable class...
R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 375

You need to post some code here, to show what efforts you have already made..
Whatever code you have implemented to get the outcome.. Or at least the idea you have.

You can get better inputs from other users.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19728

Here's a simple example:

Paul Clapham

Joined: Oct 14, 2005
Posts: 19728

By the way, I didn't post that example for a joke. It is indeed an immutable class, and it's the simplest possible example.

So now here's an exercise for you: Explain why it is immutable. (Hint: what does "immutable" mean? And does this class satisfy that definition?)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Immutable class
It's not a secret anymore!