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

31 lines
759 B
HTML

<html>
<body>
Reports methods that are named identically to their class.
While such naming is allowed by the Java language, by convention it is reserved for defining constructors.
Using it for methods is probably a mistake or bad practice.
<p><b>Example:</b></p>
<pre><code>
class MyClass {
int val;
// Method MyClass named identically to its containing class.
// Likely, 'void' was added by mistake.
void MyClass(int val) {
this.val = val;
}
}
</code></pre>
<p>When appropriate, a quick-fix converts the method to a constructor:</p>
<pre><code>
class MyClass {
int val;
MyClass(int val) {
this.val = val;
}
}
</code></pre>
<p>Another quick-fix renames the method.</p>
<!-- tooltip end -->
</body>
</html>