Enumeration and annotation of Java

JDK1. 5. The newly added enum keyword is used to define enumeration classes.

Differences between enumeration class and ordinary class:

JDK1. In 5, you can use the object of the enumeration class as the expression in the switch expression. The case clause can directly use the name of the enumeration value without adding the enumeration class as a qualification.

If enumeration has only one member, it can be used as an implementation of the singleton pattern.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>