Since Checkstyle 3.1


Ensures that identifies classes that can be effectively declared as final are explicitly marked as final. The following are different types of classes that can be identified:

  1. Private classes with no declared constructors.
  2. Classes with any modifier, and contains only private constructors.

Classes are skipped if:

  1. Class is Super class of some Anonymous inner class.
  2. Class is extended by another class in the same file.


To configure the check:

<module name="FinalClass"/>


final class MyClass { // OK
  private MyClass() { }

class MyClass { // violation, class should be declared final
  private MyClass() { }

class MyClass { // OK, since it has a public constructor
  int field1;
  String field2;
  private MyClass(int value) {
    this.field1 = value;
    this.field2 = " ";
  public MyClass(String value) {
    this.field2 = value;
    this.field1 = 0;

class TestAnonymousInnerClasses { // OK, class has an anonymous inner class.
    public static final TestAnonymousInnerClasses ONE = new TestAnonymousInnerClasses() {


    private TestAnonymousInnerClasses() {

class Class1 {

    private class Class2 { // violation, class should be declared final

    public class Class3 { // ok



Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.


Parent Module