aspose file tools*
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
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: 375
    
    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: 18908
    
    8

Here's a simple example:



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18908
    
    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?)
 
 
subject: Immutable class