This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Immutable class" Watch "Immutable class" New topic
Author

Immutable class

leela krishhna
Greenhorn

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

Joined: Aug 11, 2012
Posts: 372
    
    1

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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Here's a simple example:



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Immutable class