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

24 lines
719 B
HTML

<html>
<body>
Reports calls to <code>String.equals()</code> with a <code>CharSequence</code> as the argument.
<p>
<code>String.equals()</code> can only return <code>true</code> for <code>String</code> arguments.
To compare the contents of a <code>String</code> with a non-<code>String</code> <code>CharSequence</code> argument,
use the <code>contentEquals()</code> method.</p>
<p><b>Example:</b></p>
<pre><code>
boolean equals(String s, CharSequence ch) {
return s.equals(ch);
}
</code></pre>
<p>After quick-fix is applied:</p>
<pre><code>
boolean equals(String s, CharSequence ch) {
return s.contentEquals(ch);
}
</code></pre>
<!-- tooltip end -->
<p>
<small>New in 2017.3</small>
</body>
</html>