Modifier private is redundant for enum constructor
为什么Java枚举构造函数必须是私有的?
public or protected modifiers are not allowed with enum constructors.
枚举构造函数不允许使用public或protected修饰符。
原因
The constructor is meant to customize the creation of constants inside the enumeration once, not to create and initialize different instances of the enum (this doesn’t make sense). This is why it must be private.
构造函数旨在一次自定义枚举内部的常量的创建,而不是创建和初始化枚举的不同实例(这没有意义)。这就是为什么它必须是私有的。
如有错误,还请多多指教!
转载或者引用本文内容请注明来源及原作者:橘足轻重;