Hi, all I'm wondering why java.lang.Math should be looked at as a immutable class? Since the class doesn't have any non-final field, certainly no one could change its contents, in certain degree i think whether immuatable or mutable here make no sense. Can i say all the interfaces are immutable? thanks in advance
Yes, all wrapper classes ( Double, Long, Float etc ) are immutable. Immutability cannot be applied to interfaces since they cannot be instantiated. Hope that helps! ------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Now here is a discussion. Math can not be instansiated! The constrictor is private. Since it is final, you can not subclass it either. Therefore, you can never have a Math Object. Math is a collection of common Math methods all of which are static. If you can't create an object, you can never change it. But, if you can't create it, there isn't anything to change. ------------------ Hope This Helps Carl Trusiak, SCJP2
I might be wrong with this... (please do correct me), if the class have the constructor with private access modifier, the best way to maintain the soul of inheritance behavior is by making it final. Because if it's not, the class whose inherited from this class is capable of making error since the contsructor is private. if it's true, isn't that be nice if (in the future) the compiler will make sure that the class who has a private contructor is implicitly final ?? stevie