枚举类(Enumeration class)

枚举类是多例设计。
底层为类的成员变量创建多个对象。

枚举非常适合做信息标识和信息分类。
enum Oritation {
UP,DOWN,LEFT,RIGHT
}
比如下使用常量存储四个方向更加优雅,严谨。
public static final int UP =0;
public static final int DOWN=1;
publict static final int LEFT=2;
publict static final int RIGHT=3;

switch (Oritation oritation){
case UP://这里不需要写枚举类型,switch有自动设别
System.out.println(“Move up!”);
berak;
case DOWN:{
System.out.println(“Move down!”);
berak;

}
}

————————

Enumeration classes are multi instance designs.
Create multiple objects for the member variables of the underlying class.

Enumeration is very suitable for information identification and information classification.
enum Oritation {
UP,DOWN,LEFT,RIGHT
}
It is more elegant and rigorous than using constant storage in the following four directions.
public static final int UP =0;
public static final int DOWN=1;
publict static final int LEFT=2;
publict static final int RIGHT=3;

switch (Oritation oritation){
case UP://这里不需要写枚举类型,switch有自动设别
System.out.println(“Move up!”);
berak;
case DOWN:{
System.out.println(“Move down!”);
berak;

}
}