To write a class that is just a grouping of static methods and static fields whose design does not require a constructor to be instantiated.
// Noninstantiable utility class
public class UtilityClass {
// Suppress default constructor for noninstantiability
private UtilityClass() {
throw new AssertionError();
}
}
Because the explicit constructor is private, it is inaccessible outside the class. The AssertionError isn’t strictly required, but it provides insurance in case the constructor is accidentally invoked from within the class.
It guarantees the class will never be instantiated under any circumstances.
Jaziel Lopez, Software Engineer, TJ Area, BC. MX