Back to all rules
What this rule checks
Method name differs from its class name
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
class Ball {
  Ball() { }       // this is a constructor
  void move() { }
}
FAIL — this code triggers the rule
class Ball {
  void Ball() { }  // looks like a constructor but returns void
}
Overview
Category Topic Classes
Level Advanced
Type Built-in PMD
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
PMD reference category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass