C # Idioms:enum or enum class (enum Class)
Marshine
(Original composition format: http://www.marshine.com)
Reversion:2004/5/28
Modification Note: Thanks to the CLS compatibility issue mentioned by Ninputer, while modifying the Equals rewrite not
Java hidden box operation-enum and hidden box operation enum
Enum, which is an enumeration type, has a similar type in each programming language.
Because it is rarely used, every time I see enum, it will be daunting, because its syntax is really
Concept
enum, called enumeration, is the new feature introduced in JDK 1.5.
In Java, enum types that are decorated by keywords are enumerated types. The form is as follows:
Enum Color {RED, GREEN, BLUE}
If the enumeration does not
When I recently discussed the issue with my colleagues, my colleague suddenly mentioned why the constant values defined in Java do not take the ENMU enumeration type and are defined by the public final static type. We used to be defined in this way,
Enum, which is an enumeration type, has a similar type in each programming language.Because of the use of less, every time I see an enum will be daunting, because its grammar is really "do not press the regular card" Ah! The general enum syntax is
Question, why do constants need to be defined with an enum instead of final to define a member variable or define a constant in interface?First to understand what an enum class is: The Enum class is a class in the Java.lang package, which is the
Marshine
(Original layout format: http://www.marshine.com)
Reversion: 2004/5/28Change Description: ThanksNinputerThe CLs compatibility problem was mentioned. At the same time, the equals rewriting not mentioned in the original version was
Simple IntroductionEnum types in Java are defined by the keyword enum, a new type from jdk1.5, and all enum types inherit from the enum type. To understand enumeration types, we recommend that you first open the enum class in the JDK and simply read
Before JDK1.5, we defined constants: public static fianl ..... Now, with enumerations, you can group related constants into an enumeration type, and enumerations provide more methods than constants.public enum Color { RED, GREEN, BLANK, YELLOW
Ref:http://www.cnblogs.com/happypawpaw/archive/2013/04/09/3009553.htmlUsage One: ConstantsBefore JDK1.5, we defined constants: public static fianl ..... Now, with enumerations, you can group related constants into an enumeration type, and
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.