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="b5f1dd7beb624cef-7ff96c04-4dd94d76-8c3b95d4-8efdb872436dafd793393b45"><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="f0e0aed124397988-445cc0cd-4ecf4e68-bd719987-f98d0bc1e94de2d094192e2e"><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="ea55060a8a21ffa7-7b96b106-436d40ce-8903b20a-d47994053f9991d52e653694"><ac:plain-text-body><![CDATA[

[[Techtalk 2007

AA. Bibliography#Techtalk 07]]

"The Joy of Sets"

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

...