Files
openide/java/java-impl/resources/inspectionDescriptions/NumberEquality.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

23 lines
738 B
HTML

<html>
<body>
Reports code that uses <b>==</b> or <b>!=</b> instead of <code>equals()</code> to test for <code>Number</code> equality.
<p>
With auto-boxing, it is easy
to make the mistake of comparing two instances of a wrapper type instead of two primitives, for example <code>Integer</code> instead of
<code>int</code>.
</p>
<p><b>Example:</b></p>
<pre><code> void foo(Integer a, Integer b) {
final boolean bool = a == b;
}
</code></pre>
<p>If <code>a</code> is known to be non-null, then it's safe to apply the "unsafe" quick-fix and get the result similar to the following:</p>
<pre><code> void foo(Integer a, Integer b) {
final boolean bool = a.equals(b);
}
</code></pre>
<!-- tooltip end -->
<p>
</body>
</html>