The enum (enum) type is a new feature of Java 5, which is a novel type that allows represented to represent specific pieces of data and is all represented in type-safe form. 1, the use of constantsBefore JDK1.5, we defined constants: public static
Java enumeration class usage example
This example describes the usage of Java enumeration classes. Share it with you for your reference. The details are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2
Learn from teacher Wang Enumeration (iv): An enumeration of exercisesTeacher: Wang Shaohua QQ Group No.: 4,837,736,641, demandPlease write an enumeration about the day of the week weekdayRequirements:Enumeration value: Mon,tue,wed,thu,fri,sat,sunThe
Directly on the codeUsage one (constant):Package Com.ou.test;import Com.sun.corba.se.impl.util.sunvmcid;public class Enum {public static void main (string[ ] args) { Weekday day = weekday.five; System.out.println (day);//Direct
This article mainly introduces the use of enumeration classes in Python, for more information, see: Python Learning Guide
When we need to define constants, one way is to use uppercase variables to define them by integers, such as the month:=1=2=
The examples in this article describe the Java enumeration class usage. Share to everyone for your reference. Specifically as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 This is the same as the
package com.
The enum (enum) type is a new feature of Java 5, which is a novel type that allows represented to represent specific pieces of data and is all represented in type-safe form. 1, the use of constantsBefore JDK1.5, we define constants that are:
Networkcomms.net2.3.1 Open source version, based on GPL V3 protocol. Because the 3.x version of the source code can not be published, so based on this version of learning.3. There are many improvements and bug fixes in the X version, and there is
The examples in this article describe the Java enumeration class usage. Share to everyone for your reference. as follows:
Package com.school.stereotype;
/** * Active Enumeration type * @author Qixuan.chen/public enum EventStatus {/** * not
The enum keyword is used to define an enumeration class, which can be implemented as a singleton mode if the enumeration has only one member.The properties of an enum class object should not be allowed to be altered, so you should use thePrivate
1. Enumeration class overviewThe enum keyword, used to define an enumeration class, that is the same as the Class,interface keyword. An enumeration class is a special class.But the enumeration class is not a normal class after all, it differs from
1. Before the enumeration, we need some constants, for example, we want to use some constants to replace the order of several states, such as the orders have not been paid, the payment has not been shipped, shipped unconfirmed receipts, received non-
Enumerations are enumerated, often used to represent collections that can be explicitly scoped, such as gender, season, week, month, and so on.
The enumeration class appears in JDK 1.5, and before the enumeration class is present, we want to show
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. The list of enumerated elements must be written at the top of the enumeration class, separated by commas, and if there is no other content after the end of the list of elements, you may not write a semicolon or you must write.
2. All constructors
In some cases, the object of a class is limited and fixed, such as the season class, it has only 4 objects: Spring, summer, autumn, winter. This example of a finite and fixed class, in Java, is called an enumeration class.1 Manually implementing an
1. Variable Parameters
Starting with JDK 1.5, Java allows you to define parameters with variable parameter lengths, allowing you to specify an indeterminate number of formal parameters for a method, or add three points after the type of the last
Application ScenariosBecause singleton mode generates only one instance, it reduces system performance overhead (e.g., when an object is generated that requires more resources, such as reading a configuration and generating other dependent objects,
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.