Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The list itself is immutable because you cannot add/remove elements. The elements are on their own regarding immutability. In more precise terms, we have definitions from <a href="http://docs.oracle.com/javase/1.4.2/docs/guide/collections/overview.html" rel="nofollow noreferrer">a historical Java 1.4.2 document</a>:</p> <blockquote> <ul> <li>Collections that do not support any modification operations (such as add, remove and clear) are referred to as unmodifiable. Collections that are not unmodifiable are referred to modifiable.</li> <li>Collections that additionally guarantee that no change in the Collection object will ever be visible are referred to as immutable. Collections that are not immutable are referred to as mutable.</li> </ul> </blockquote> <p>Note that for these definitions to make any sense we must assume an implicit distiction between a <em>collection</em> in an abstract sense and an object that <em>represents that collection</em>. This is important because <strong>the object that represents an immutable collection is not itself immutable</strong> by any standard definition of that term. For example, its <code>equals</code> relation has no temporal consistency, a vital requirement on immutable objects.</p> <p>As far as defensive copying, note that is an ill-defined problem in general and there will never be a general immutable collection in Java that will manage to defensively copy its elements. Note additionally that such a collection would be <strong>less useful</strong> than the immutable collections that really exist: when you put an object into a collection, in 99.99% cases you want <strong>that very object</strong> to be there, not some other object that is not even <em>equal</em> to it.</p> <p>There is a quite standard definition of <em>object immutability</em> (as opposed to <em>collection immutability</em>) which assumes transitive immutability of the whole object graph reachable from the immutable object. Taken too literally, though, such a definition will almost never be satisfied in the real world. Two cases in point:</p> <ul> <li><strong>nothing is immutable</strong> in the face of reflection. Even <code>final</code> fields are writable.</li> <li>even <code>String</code>, that bastillon of immutability, <a href="https://stackoverflow.com/questions/11146255/how-to-create-mutable-java-lang-string">has been proven mutable</a> outside the Java sandbox (without a <code>SecurityManager</code>&mdash;which covers 99% of real-world Java programs).</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload