Inspectopedia Help

Declaration can have 'final' modifier

Reports fields, methods, or classes that may have the final modifier added to their declarations.

Final classes can't be extended, final methods can't be overridden, and final fields can't be reassigned.

Example:

public class Person { private String name; Person(String name) { this.name = name; } public String getName() { return name; } public String toString() { return getName(); } }

After the quick-fix is applied:

public final class Person { private final String name; Person(String name) { this.name = name; } public final String getName() { return name; } public final String toString() { return getName(); } }

Use the Report classes and Report methods options to define which declarations are to be reported.

Inspection options

Option

Type

Default

Report classes

Checkbox

false

Report methods

Checkbox

false

Report fields

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023