-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEnumDemo.java
33 lines (23 loc) · 1.1 KB
/
EnumDemo.java
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
package nadine;
public class EnumDemo {
// Define two enum types -- remember that the definitions
// go OUTSIDE the main() routine!
enum Day {SUNDAY, MONDAY, TUESDAY,WEDNESDAY,THURSDAY, FRIDAY, SATURDAY;
enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC;
public static void main(String[] args) {
Day tgif; //Declare a variable of type Day.
Month libra; // Declare a variable of type Month.
tgif = Day.FRIDAY; // Assign a value of type Day to tgif.
libra = Month.OCT; // Assign a value of type Month to libra.
System.out.print("my sign is libra, since i was born in ");
System.out.println(libra); // output value will be: OCT
System.out.print("that's the ");
System.out.print(libra.ordinal() );
System.out.println("-th month of the year.");
System.out.println(" ( counting from 0, of course!)");
System.out.print("Isn't it nice to get to ");
System.out.println(tgif); // Output value will be: FRIDAY
System.out.println( tgif + " is the " + tgif.ordinal()
+ "-th day of the week.");
}
}