Back to Intellij Community

ComparisonOfShortAndChar

java/java-impl/resources/inspectionDescriptions/ComparisonOfShortAndChar.html

2025.3-rc-2292 B
Original Source

Reports equality comparisons between short and char values.

Such comparisons may cause subtle bugs because while both values are 2-byte long, short values are signed, and char values are unsigned.

Example:

if (Character.MAX_VALUE == shortValue()) {} //never can be true