mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
23 lines
738 B
HTML
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> |