-
Notifications
You must be signed in to change notification settings - Fork 0
/
hs.java
35 lines (34 loc) · 942 Bytes
/
hs.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
34
35
import java.util.*;
public class hs {
public static void main(String[] args) {
HashSet<Integer> set = new HashSet<Integer>();
set.add(88);
set.add(44);
set.add(2);
set.add(90);
set.add(75);
set.add(12);
set.add(52);
set.add(75);
System.out.println("Output :");
for (Integer ele : set) {
System.out.print(ele+" ");
}
HashSet<Integer> ODD = new HashSet<Integer>();
HashSet<Integer> EVEN = new HashSet<Integer>();
for (Integer ele : set) {
if (ele % 2 != 0)
ODD.add(ele);
else
EVEN.add(ele);
}
System.out.println("\nODD :");
for (Integer ele : ODD) {
System.out.print(ele);
}
System.out.println("\nEVEN :");
for (Integer ele : EVEN) {
System.out.print(ele+" ");
}
}
}