Wiki Markup |
---|
The {{char}} type is the only unsigned primitive type in Java. As a result, a signed value cannot be stored and retrieved successfully; its representable range of values contains only non-negative values. Consequently, attempting to store and retrieve a value from a variable of type {{char}}. In particularany of the other integral primitive types will produce unexpected results when that value is negative. Similarly, comparing a value of type {{char}} with any negative number will never yield {{true}}. However, because the method {{read()}} returns -1 to indicate the End of File ({{EOF}}) condition, it is tempting to compare the character returned by {{read()}} with -1. This is a common error \[[Pugh 2008|AA. Bibliography#Pugh 08]\] is illustrated below. |
Noncompliant Code Example
...