aspose file tools*
The moose likes Beginning Java and the fly likes Mutable or Immutable. How to find? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Mutable or Immutable. How to find?" Watch "Mutable or Immutable. How to find?" New topic
Author

Mutable or Immutable. How to find?

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Could you please tell me how to find whether a class is mutable or immutable.
Thanks


SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

It's not any special property of the language -- i.e., there's no "immutable" keyword. The only thing you can do is to read the Javadoc for the class and see what it says.


[Jess in Action][AskingGoodQuestions]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
ransika,
Why are you trying to figure this out? What problem are you trying to solve?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Could you please tell me how to find whether a class is mutable or immutable.
If there is no way to set the member variables of the class (typically by calling the setXXX() methods) except in the constructor, the objects of that class are immutable.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Not quite true. See the article in the JavaRanch April Newsletter
Mutable and Immutable Objects
Dave
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Not quite true. See the article in the JavaRanch April Newsletter
Mutable and Immutable Objects

Point well taken. Of course, I didn't mentioned the fact that the object can be mutated indirectly by manipulating the reference to its internal mutable fileds. Nice article, David!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mutable or Immutable. How to find?