公共类CommonUtil中不应该有公开的构造函数

Sonar静态代码检查发现下面缺陷:

Utility classes should not have a public constructor

Utility classes, which are a collection of static members, are not meant to be instantiated. Even abstract utility classes, which can be extended, should not have public constructors.
Java adds an implicit public constructor to every class which does not define at least one explicitly. Hence, at least one non-public constructor should be defined.

以后凡是公共的类都需要在里面定义该类的private的构造函数,譬如CommonUtil方法中要定义一个
private CommonUitl(){

}

你可能感兴趣的:(公共类CommonUtil中不应该有公开的构造函数)