Use of enum enumerations in Java

Source: Internet
Author: User

Note Item:

1. Using enumerations in switch can make your code more readable. 2. If you want to customize a method, you must add a semicolon at the end of the enum instance sequence. And Java requires that an enum instance be defined first. 3. All enumerations inherit from the Java.lang.Enum class, and because Java does not support multiple inheritance, the enumeration object can no longer inherit from other classes. 4. If you want to have the enumeration corresponding to the value, then write the constructor method, you can also overwrite the ToString () method

Use of enum enumerations in Java

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.