Skip to content

Commit 04f6833

Browse files
Add files via upload
1 parent 34ff1e6 commit 04f6833

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

EnumSetDemo.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package EnumSet;
2+
3+
import java.util.EnumSet;
4+
import java.util.HashSet;
5+
import java.util.TreeSet;
6+
7+
enum Days {
8+
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
9+
}
10+
11+
enum Months {
12+
JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER;
13+
}
14+
public class EnumSetDemo {
15+
16+
17+
18+
public static void main(String[] args) {
19+
EnumSet<Days> set1 = EnumSet.allOf(Days.class);
20+
HashSet<Months> set2 = new HashSet<>();
21+
TreeSet<Days> set3 = new TreeSet<>();
22+
set2.add(Months.JANUARY);
23+
set3.addAll(set1);
24+
System.out.println(set2);
25+
System.out.println(set3);
26+
27+
28+
}
29+
}
30+
31+

0 commit comments

Comments
 (0)