We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09ce102 commit 8e373e7Copy full SHA for 8e373e7
EnumaratedTypes/Example.java
@@ -0,0 +1,37 @@
1
+/**
2
+ * @author viktorvoltz
3
+ */
4
+public enum Example {
5
+ WALK("press to walk"),
6
+ RUN("press to run"),
7
+ JUMP("press to jump"),
8
+ SIT("press to sit");
9
+
10
+ private String description;
11
12
+ private Example(String description){
13
+ this.description = description;
14
+ }
15
16
+ @Override
17
+ public String toString() {
18
+ String id = name(); //name from java.lang.Enum.name()
19
+ return id;
20
21
22
+ public String getDescription(){
23
+ return description;
24
25
26
+ public static void main(String[] args) {
27
+ for(Example e : Example.values()){
28
+ System.out.println(e + ": " + e.getDescription());
29
30
31
+}
32
+/*
33
+WALK: press to walk
34
+RUN: press to run
35
+JUMP: press to jump
36
+SIT: press to sit
37
+*/
0 commit comments