Inspectopedia Help

Utility class with 'public' constructor

Reports utility classes with public constructors.

Utility classes have all fields and methods declared as static. Creating a public constructor in such classes is confusing and may cause accidental class instantiation.


public final class UtilityClass { public UtilityClass(){ } public static void foo() {} }

After the quick-fix is applied:

public final class UtilityClass { private UtilityClass(){ } public static void foo() {} }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Java, 233.SNAPSHOT

Last modified: 13 July 2023