Instantiate enum class

后端 未结 9 1517
南笙
南笙 2020-12-03 05:34

Consider I am having the following enum class,

public enum Sample {
    READ,
    WRITE
}

and in the following class I am trying to test th

9条回答
  •  [愿得一人]
    2020-12-03 06:21

    Enums doesn't support public constructors and hence, cannot be instantiated. Enums are for when you have a fixed set of related constants. Exactly one instance will be created for each enum constant.

提交回复
热议问题