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 Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java" Watch "Java" New topic


Suhail Mohammed

Joined: Mar 26, 2007
Posts: 4
How to make a class immutable???
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15045

Welcome to JavaRanch.

Do you know exactly what "immutable" means?

To make a class immutable, make sure that it does not have any non-private methods that change the internal state of instances of the clas (i.e. methods that change the values of member variables).

Also please use a meaningful subject line instead of "Java" when you ask a question.
[ March 26, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Java
It's not a secret anymore!