Bubble distribution chart (the larger the circle, the greater the importance), the top 10 big data tools that are most favored are Hadoop, Java, Spark, Hbase, Hive, Python, Linux, Strom, Shell programming, and MySQL. Both Hadoop and Spark are distributed parallel computing frameworks, which now seem to dominate Hadoop and spark is behind, but Spark has a catch-up trend. Hadoop is implemented by Java, so it's not surprising that Java is behind the que
",3), Yello ("Yellow",4);
Member variables
private String name;
private int index;
Construction method
Private Color (String name, int index) {
THIS.name = name;
This.index = index;
}
Common methods
Public static String getName (int index) {
For (Color c:color.values ()) {
if (c.getindex () = = index) {
return c.name;
}
}
return null;
}
Get Set method
Public String GetName () {
return name;
}
Public v
caseyellow:color=signal.red; Break casegreen:color=signal.yellow; Break }}} Use three: Add a new method to the enumeration if you intend to customize your own method, you must add a semicolon at the end of the enum instance sequence. And Java requires that an enum instance be defined first. Java Code publicenumcolor{Red ("Red", 1), green ("green", 2), blank ("white", 3), yello ("* * *", 4); Member Variable privatestringname; privateintindex;
customize your own method, you must add a semicolon at the end of the enum instance sequence. And Java requires that an enum instance be defined first.public enum Color ( "Red", 1), Green ("green", 2), BLANK ("White", 3), Yello ("Yellow", 4); Member variable private String name; private int index; Construction Method Private Color (String name, int index) { this.name = name; This.index = index; } Normal method pu
Dk1.5A new type-enumeration is introduced. InJavaAlthough it is a "small" function, it brings great convenience to my development. Usage 1: Constant
InJdk1.5Previously, we defined constants:Public static fianl ..... Now, with enumeration, You can group related constants into one Enumeration type, and enumeration provides more methods than constants.
Public Enum color {red, green, blank, yellow}
Usage 2: Switch
The switch statement before jdk1.6 only supports int, Char, and enum types.C
that the enum instance be defined first.
Java code
Public enum Color {
RED ("RED", 1), GREEN ("GREEN", 2), BLANK ("white", 3), YELLO ("yellow", 4 );
// Member variable
Private String name;
Private int index;
// Constructor
Private Color (String name, int index ){
This. name = name;
This. index = index;
}
// Common method
Public static String getName (int index ){
For (Color c: Color. values ()){
If (c. getIndex () = index ){
Return c.
Usage One: ConstantsBefore JDK1.5, we define constants that are: publicstaticfianl ..... Now, with enumerations, you can group related constants into an enumeration type, and enumerations provide more methods than constants.Java code
Public enum Color {
RED, GREEN, BLANK, YELLOW
}
Usage Two: SwitchThe switch statement before JDK1.6 only supports int,char,enum types, and using enumerations can make our code more readable.Java code
Enum Signal {
GREEN, YELLOW, RED
}
the enum instance sequence. and Java requires that an enum instance be defined first . Java code
public enum Color {
Red ("Red", 1), Green ("green", 2), BLANK ( "White", 3), Yello ("Yellow", 4);
//member variables
Private String name;
Private int index;
//Construction method
Private Color (String name, int index) {
This . Name = name;
This . Index = index;
}
//Common method
p
Usage One: Constants
Before JDK1.5, we defined constants as: publicstaticfianl ... Now that you have enumerations, you can group related constants into an enumeration type, and enumerations provide more methods than constants.
Java code
public enum Color {
RED, GREEN, BLANK, Yellow
}
Usage Two: Switch
The switch statement before JDK1.6 only supports the Int,char,enum type, and using enumerations makes our code more readable.
Java code
Enum Signal {
GREEN, yellow, RED
. RED; break; case GREEN: color = Signal. YELLOW; break ;}}usage 3: Add a new method to enumeration. If you want to customize your own method, you must add a semicolon at the end of the enum instance sequence. In addition, Java requires that the enum instance be defined first. Java code public enum Color {RED ("RED", 1), GREEN ("GREEN", 2), BLANK ("white", 3 ), YELLO ("***", 4); // member variable private String name; private int index; // constructor
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.