Versions Compared

Key

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

...

Wiki Markup
This noncompliant code example prints {{100}} as the size of the {{HashSet}} rather than the expected result ({{1}}). The combination of values of types {{short}} and {{int}} in the operation {{i-1}} causes the result to be autoboxed into an object of type {{Integer}}, rather than one of type {{Short}}. See guidelinerule "[NUM18-J. Be aware of numeric promotion behavior]" for additional explanation of the details of the promotion rules. The {{HashSet}} contains only values of type {{Short}}; the code attempts to remove objects of type {{Integer}}. Consequently, the {{remove()}} operation accomplishes nothing. The language's type checking guarantees that only values of type {{Short}} can be inserted into the {{HashSet}}.  Nevertheless, programmers are free to attempt to remove an object of _any_ type because {{Collections<E>.remove()}} accepts an argument of type {{Object}} rather than of type {{E}}. Such behavior can result in unintended object retention or memory leaks \[[Techtalk 2007|AA. Bibliography#Techtalk 07]\]. 

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="485354c81318cf0a-6a9cf536-4f0b4530-97f88445-24393776191e0766e4b3f599"><ac:plain-text-body><![CDATA[

[[Core Java 2004

AA. Bibliography#Core Java 04]]

Chapter 5

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="02141579f91d9b79-d4a4d1cc-487d451f-9479bd62-37cbfe63ccdb9291d1c5f8a9"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[§5.1.7, "Boxing Conversions"

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

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c41e22ccf1da1a01-6cbc731c-4bc144f0-94c9a4e8-2d86de8f27ec237b362f2847"><ac:plain-text-body><![CDATA[

[[Techtalk 2007

AA. Bibliography#Techtalk 07]]

"The Joy of Sets"

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

...