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="97a3591fc18d0d57-77301147-48d7435b-9f31a6e4-ba929f375152ebc0c3807e48"><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="5391ef7b27a2492e-96a12f0e-412c48f1-a4a59618-0320ed8c0b105ddc89e12499"><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="9a9c8e31226f1650-114488df-49f4480f-9ee39451-22bdf6a665ff3d298bd985a0"><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="82b323385a6507aa-0ea99534-4f8148f8-a6e9b7e8-3da95ce26c366d2c92a2952e"><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="cbb92210581816b9-7807d8a4-4dfa488c-880e930a-26efefa23b98194db3bed297"><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="2fef256c0ad1c731-3cd0ffba-44ad45bd-bbf1b5bb-b4788f070fb1242f7351620b"><ac:plain-text-body><![CDATA[

[[Security 2006

AA. References#Security 06]]

 

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

...