Home > Java > javaTutorial > Java Programming Thoughts Learning Class (6) Chapter 19 - Enumeration Type

Java Programming Thoughts Learning Class (6) Chapter 19 - Enumeration Type

php是最好的语言
Release: 2018-08-09 14:55:52
Original
3086 people have browsed it

19.4 The mystery of values()

By decompiling the enumeration class, values() is a static() method added by the compiler. The compiler marks the enumeration class (enum) as a final class, so the enum class cannot be inherited.

19.5 Implementation rather than inheritance

All enum classes inherit from the java.lang.Enum class. Since Java does not support multiple inheritance, your enum class cannot inherit other classes. However, when we create a new enum, we can implement one or more interfaces at the same time.

19.9 Using EnumMap

Like EnumSet, the order in which enum instances are defined determines their order in EnumMap.
 Constant-specific methods.
 Multiple dispatching.

19.10 Methods related to constants

 Through the corresponding enum instance, we can call the methods on it. This is also often called table-driven code (note its similarity to the command pattern mentioned earlier).

19.10.1 Chain of Responsibility using enum

chain of Responsibility.

19.11.1 Using enum distribution

ONE way is to use a constructor to initialize each enum instance and take a "set" of results as parameters. The two are put together to form a structure similar to a query table.

Related articles:

Java Programming Thought Learning Class (4) Chapter 17 - In-depth Discussion of Containers

Java Programming Thought Learning Class (5) Chapter 18-Java IO System

The above is the detailed content of Java Programming Thoughts Learning Class (6) Chapter 19 - Enumeration Type. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template