Java Basics Learning--------enum type (1)

Source: Internet
Author: User

The concept of enum types:

1 /**2 * Purpose: Enum type3  * @authorChenyanlong4 * Date: 2017/10/225 * Website:http://blog.csdn.net/sup_heaven/article/details/352958516  */7  PackageCom.mon10.day22;8 9  Public classEnumdemoone {Ten  One     //declaring enum types A     Private enuminnerenum{ - Red,green,yellow -     }; the      -      Public Static voidMain (string[] args) { - System.out.println (innerenum.green); -     } +}

Run the above code to produce the edits Enumdemoone.class and Enumdemoone$innerenum.class.

This means that defining an enumeration type is actually defining a class, except that a lot of details are being filled by the compiler, so To some extent, the enum keyword acts like a class or interface. When you use an enum to define an enumeration type, the type that is actually defined is inherited from the Java.lang.Enum class. each enumerated member is actually an instance of the defined enumeration type, and they are all default to final. The values set by the constant name cannot be changed, and they are also members of public and Static, which is the same as the constant limit in the interface. They can be used directly from the class name.

Java Basics Learning--------enum type (1)

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.