Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
class MixedTypesListUtility {
  private static void addToList(List list, Object obj) {
    list.add(obj); // unchecked warning
  }

  public static void main(String[] args) {
    List<String> list = new ArrayList<String> ();
    addToList(list, 1);
    System.out.println(list.get(0));
  }
}

...

Code Block
bgColor#ccccff
class ParameterizedListUtility {
  private static void addToList(List<String> list, String str) {
    list.add(str);     // No warning generated
  }

  public static void main(String[] args) {
    List<String> list = new ArrayList<String> ();
    addToList(list, "1");
    System.out.println(list.get(0));
  }
}

...

Code Block
bgColor#ccccff
class MixedTypesListUtility {
  private static void addToList(List list, Object obj) {
    list.add(obj); // Unchecked warning
  }

  public static void main(String[] args) {
    List<String> list = new ArrayList<String> ();
    List<String> checkedList = Collections.checkedList(list, String.class);
    addToList(checkedList, 1);
    System.out.println(list.get(0));
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9bbdffd0f26cf461-4ab9d919-4ff54712-9a1fa99d-ca1839c487f47873da46d3ec"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 23. Don't use raw types in new code

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b04aeff0d33a7431-75d470f5-45454267-a7089e1b-f68cf5403221cae25500133e"><ac:plain-text-body><![CDATA[

[[Bloch 2007

AA. Bibliography#Bloch 07]]

Generics, 1. Avoid raw types in new code

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="57b690a48ef4b689-81ad4c32-49ff4291-a897a2a9-ac043e0ad3eb42d0b568ac33"><ac:plain-text-body><![CDATA[

[[Bloch 2005

AA. Bibliography#Bloch 05]]

Puzzle 88. Raw Deal

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="32bc71301dc7d21f-4c1d1ad1-4e994432-9e61ac02-71028d4ce3682e168c86e3b7"><ac:plain-text-body><![CDATA[

[[Darwin 2004

AA. Bibliography#Darwin 04]]

8.3, Avoid Casting by Using Generics

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0ca9266867431e82-083bfb4f-4f6d40f7-9a3f8c31-3ae8de4d5028305a6bc4c76d"><ac:plain-text-body><![CDATA[

[[JavaGenerics 2004

AA. Bibliography#JavaGenerics 04]]

 

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2ba67ba7d4fdccef-2d3ad3f0-415b4dfc-a12686dc-14c740c3c9e569c76d7a6750"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[Chapter 5, Conversions and Promotions

http://java.sun.com/docs/books/jls/third_edition/html/conversions.html]

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

 

§4.8, Raw Types

 

§5.1.9, Unchecked Conversion

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="58bfcebcdcc138ff-d1551118-48164484-a54da053-e706106799feed85a358f33f"><ac:plain-text-body><![CDATA[

[[Langer 2008

AA. Bibliography#Langer 08]]

Topic 3, [Coping with Legacy

http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#Topic3]

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b49578c5867b392b-1c7ff5b5-445947f0-aab1b980-00b718078a255ad3ee38e470"><ac:plain-text-body><![CDATA[

[[Naftalin 2006

AA. Bibliography#Naftalin 06]]

Chapter 8, Effective Generics

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="abce22d82db88153-0630ca59-4f484968-81cca735-f4bf61ea0f48eddfbaa1a9fb"><ac:plain-text-body><![CDATA[

[[Naftalin 2006b

AA. Bibliography#Naftalin 06b]]

Principle of Indecent Exposure

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="133f102524ca88ea-4b00d5b2-4b764b75-803585f1-44b12e9cb110f15180a5fcf2"><ac:plain-text-body><![CDATA[

[[Schildt 2007

AA. Bibliography#Schildt 07]]

Create a checked collection

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

...