Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
class MutableClass {
  private Date[] date;

  public MutableClass() {
    date = new Date[20];
    for (int i = 0; i < date.length; i++) {
      date[i] = new Date();
    }
  }

  public Date[] getDate() {
    return date; // or return date.clone()
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="de2b0d72af651b6e-568a843b-47ad497d-8b92a9a3-50f88323507575552d24a8b7"><ac:plain-text-body><![CDATA[

[[API 2006

AA. References#API 06]]

[Method clone()

http://java.sun.com/javase/6/docs/api/java/lang/Object.html#clone()]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="354db4746becd987-1380c640-48514f4f-bebb955e-57519d7b68557c1f594e906d"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. References#Bloch 08]]

Item 39. Make defensive copies when needed

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="27f04a7d7c0086e0-2b3d1d35-4dc148fa-b3e7a8ec-46c140e64a1264fe0f8ef764"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. References#Goetz 06]]

3.2, Publication and Escape: Allowing Internal Mutable State to Escape

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="87860f4de52a55de-af248175-4e7046d6-a9b981af-9221ce7b850fdd8b817214b0"><ac:plain-text-body><![CDATA[

[[Gong 2003

AA. References#Gong 03]]

9.4, Private Object State and Object Immutability

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2dccb308217f1bcd-88aaef33-4d074561-bf699494-901794a0ae523aa58689d799"><ac:plain-text-body><![CDATA[

[[Haggar 2000

AA. References#Haggar 00]]

[Practical Java Praxis 64. Use clone for immutable objects when passing or receiving object references to mutable objects

http://www.informit.com/articles/article.aspx?p=20530]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0a58143179133eee-2a97f352-452e438c-a5cd8cf3-527bd0d13006ba75f3feedab"><ac:plain-text-body><![CDATA[

[[Security 2006

AA. References#Security 06]]

 

]]></ac:plain-text-body></ac:structured-macro>

...