• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

java.lang.Math is immutable?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I love java philosophy . "I can't exist, therefore I can't be immutable". . . .
 
Ranch Hand
Posts: 400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic