Results 1 to 2 of 2
  1. #1
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,023
    Rep Power
    6

    Default Undocumented Immutability of Classes

    I have been looking at Integer and Color and based solely on the source code, available
    documentation, and my own testing have concluded that those two classes (and probably
    the other primitive wrapper classes as well) are immutable. However, no where have I found
    where that particular trait is documented. So I have either missed something and my conclusions
    are wrong, or that the door has been left open to allow mutable operations to be added later.

    Any thoughts?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default Re: Undocumented Immutability of Classes

    The API docs for the Integer class starts with "The Integer class wraps a value of the primitive type int in an object"; the clue is the verb "wraps"; wrapping is not just "having a member", but I agree, a bit more verbosity wouldn't hurt ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. not compiling classes to target/ classes
    By vandunen in forum Apache Maven
    Replies: 0
    Last Post: 11-12-2013, 05:55 PM
  2. String Immutability and Memory
    By allaudin in forum New To Java
    Replies: 5
    Last Post: 08-27-2013, 04:50 PM
  3. Classes Help!!! two classes with object question.
    By stuckonjava in forum New To Java
    Replies: 16
    Last Post: 02-10-2012, 02:39 AM
  4. Immutability compromised if 'final' is omitted?
    By JUser in forum Advanced Java
    Replies: 1
    Last Post: 09-28-2010, 10:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •