-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEnterPoint.java
More file actions
executable file
·61 lines (48 loc) · 1.31 KB
/
EnterPoint.java
File metadata and controls
executable file
·61 lines (48 loc) · 1.31 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** ïðîåêò, êîòîðûé äåìîíñòðèðóåò èñïîëüçîâàíèå Enum */
public class EnterPoint {
private static void debug(Object information){
System.out.println(information);
}
public static void main(String[] args){
debug("-- begin --");
debug(" simple Example ");
Variables v1=Variables.V_1;
Variables v2=Variables.V_2;
debug("Value(1):"+v1.name());
debug("Value(2):"+v2.name());
debug("String to Variable:"+Variables.valueOf("V_3").name());
debug("Value(1) order:"+v1.ordinal());
debug("Value(2) order:"+v2.ordinal());
debug(" complex example ");
Widths w1=Widths.W_1;
Widths w2=Widths.W_3;
debug("Widths: "+w1.getValue()+" ("+w1.getValue()+")");
debug("Widths: "+w2.getValue()+" ("+w2.getValue()+")");
debug("-- end --");
}
}
/** declaration of enumeration type */
enum Variables {V_1, V_2, V_3};
/** declaration of enumeration type with parameters */
enum Widths{
/** width of first */
W_1(5),
/** width of second */
W_2(7),
/** width of third */
W_3(12),
/** width of fourth */
W_4;
private int value;
Widths(int value){
System.out.println("constructor:"+value);
this.value=value;
}
Widths(){
System.out.println("constructor");
this.value=-1;
}
public int getValue(){
return this.value;
}
}