mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
31 lines
759 B
HTML
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> |