my dog learned polymorphism
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: 19741

Here's a simple example:

Paul Clapham

Joined: Oct 14, 2005
Posts: 19741

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:
subject: Immutable class
jQuery in Action, 3rd edition