Java Programming thought Lesson (vi) 19th-enumeration type

Source: Internet
Author: User

The Mystery of 19.4 values ()

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

19.5 implementations rather than inheritance

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

19.9 using Enummap

As with Enumset, the order in which an enum instance is defined determines its order in Enummap.
Constant-related methods (Constant-specific methods).
Multi-channel distribution (multiple dispatching).

19.10 Constants-related methods

With the corresponding enum instance, we can invoke the method on it. This is often referred to as table-driven code (Table-driven, note the similarity to the previously mentioned command pattern).

19.10.1 the responsibility chain for using enum

Responsibility chain (Chain of Responsibility).

19.11.1 using enum distribution

One way is to use a constructor to initialize each instance of an enum and take a "set of" results as parameters. The two are placed together, forming a structure similar to the query table.

Related articles:

Java Programming thought Lesson (iv) 17th chapter-Container in-depth discussion

Java Programming Thought Lesson (v) 18th Chapter-java IO system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.