Previously, I had to struggle with the enum class. One problem was that I had to output the type name for debugging.I tried to reload the output today. I didn't expect it to work.The test is as follows,
# Include using namespace std; enum class
1, the enumeration class is also a class, you can have attributes, and so on:public enum Seasonenum{spring,summer,fall,winter;}This is not the other attribute.Package Com.creditharmony.adapter.testcase.test;public class Enumtest {public void judge
In some cases, the object of a class is limited and fixed, such as the seasonal class, which has only 4 objects. This example of a finite and fixed class, in Java, is called an enumeration class.In the early days, the enumeration classes might be
1 //To implement an enumeration class manually2 //Steps31. Hide the constructor with private42. Use public for all possible instances of this classStaticFinal-Modified class variable to hold53if necessary, you can provide some static methods that
When you write an enumeration class, if there are no enumerated values written in the first line of the enumeration class, a compile error occurs: Syntax error on token "String", STRICTFP expectedLike what:Public enum Season2 implements Timeinfo
This article is mainly about enumeration types of the base class enum class to do an introduction:First, the Enum class is located under the Java.lang package, and according to the class's introduction, the Enum class is the parent of all
Create a model in which you write a method that gets the enumeration classClass Student extends zend_db_table{protected $_name = ' student ';Protected $_primary = ' id ';function Getpartyenum ($enumname) {Adapter and get the data$db =
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
The enumeration definition should use the Npower of 2 as much as possible. If int32 is used to inherit long
[Flags] Public Enum privacyitem: Long { CommonName = 1, email = 2, mobile = 4, Birthday = 8, cardid = 16, }
Assignment
Privacyitem
Create a new enumeration class: Public enum enum1 {red ("Scarlet"), BLACK, GREEN, YELLOW, BLUE; Private String cum; Private enum1 () {//Private construction method (must be set to private because the enumeration itself is a singleton mode.) ) }
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
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
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
[JAVA Basics] enumeration, java EnumerationEnumeration
Create a finite set as a new type, and the values in the set can be used as program components;Enumeration Basic Features
The following code is a simple example of enumeration:
Returns the enum
A friend took a picture in his circle of friends, clicked on the big picture, and scanned it with appreciation. Well, it's not seen for a few months, and it's pretty again... why? Wait. What is it with her?Cool shape! Metal border! Micro camera! Isn'
(1) Static importThe import technology is actually in Java for the convenience of using other people to write good classes.Import java.lang.*| class nameOnly classes can be imported in the original Guide package statement. If you need to import some
Classes and Inheritance
class
Declaring a class using the keyword class in Kotlin
Class Invoice {
}
A class declaration consists of a class name, a class header (specifying its type parameter, a main constructor, and so on) and a class body
Enumerationenumerations are user-defined types that contain a set of named integer constants called enumerators.Grammar
unscoped enum:
enum [identifier] [: Type]
{enum-list};
scoped enum:
enum [class|struct]
[identifier] [: Type]
An explanation of the enumeration types in Java:Simple example: Public enum color{ red,blue,black,yellow,green } Complex examples (with custom construction methods and types) Public enumenumtest {FRANK ("The given name of me"), LIU ("The
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.