java learning route__advanced development__enumeration__4

enumerate

One: multiple instances and enumeration

Understand the multi-instance design pattern: the constructor is privatized, and several instantiated objects are required to be returned by the Static method inside the class.

Enumeration is an advanced multi-instance design pattern

Two: Enum class

Enum is a keyword, using the keyword to define an entity class that inherits the abstract Enum

Three: define other structures in the enumeration

Enumeration class has a lot of content, the enumeration object is in the first line of the class

The constructor of an enumeration class cannot use public and should use private

Enumeration can also implement interfaces, and there is no special use for the time being

Four: enumerate applications

enum defines an enum class representing gender

Enumeration can also support switch judgment

For enumeration, because the appearance of enumeration is relatively late, it is not recommended to use it in development.

Recording time: (April 25, 2017 12:19 Enumeration is what java has learned from other languages. The enumeration in java has more functions than other languages, but it does not seem to be very useful)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324895326&siteId=291194637