mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-01 09:04:15 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
25 lines
730 B
HTML
25 lines
730 B
HTML
<html>
|
|
<body>
|
|
Reports code that uses of <b>==</b> or <b>!=</b> to compare strings.
|
|
<p>
|
|
These operators determine referential equality instead of comparing content.
|
|
In most cases, strings should be compared using <code>equals()</code>,
|
|
which does a character-by-character comparison when the strings are different objects.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
void foo(String s, String t) {
|
|
final boolean b = t == s;
|
|
}
|
|
</code></pre>
|
|
<p>If <code>t</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(String s, String t) {
|
|
final boolean b = t.equals(s);
|
|
}
|
|
</code></pre>
|
|
|
|
<!-- tooltip end -->
|
|
<p>
|
|
|
|
</body>
|
|
</html> |