TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
TIOBE - Java Coding Standard

Rule:  Design1Checked automatically with code checker

Synopsis:Classes with only static methods should have a private constructor
Severity Level:3


If you have a class that has nothing but static methods, it allows either one instance or none at all. In either case a private constructor should be used. This also holds in case exactly one instance is allowed, because the Singleton pattern uses a private constructor.

Note that this doesn't apply to abstract classes, since their subclasses may well include non-static methods.

public class MaybeASingleton {
 public static void foo() {}
 public static void bar() {}