-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTreeSetDemo14.java
45 lines (38 loc) · 1.26 KB
/
TreeSetDemo14.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
36
37
38
39
40
41
42
43
44
45
package TreeSet;
import java.util.Iterator;
import java.util.TreeSet;
public class TreeSetDemo14 {
public static void main(String[] args) {
TreeSet<Float> ts = new TreeSet<>();
TreeSet<Float> ts1 = new TreeSet<>();
ts.add(10.58f);
ts.add(20.78f);
ts.add(30.65f);
ts.add(40.78f);
ts.add(50.98f);
ts.add(60.65f);
ts1.add(10.55f);
ts1.add(25.88f);
ts1.add(34.65f);
ts1.add(45.78f);
ts1.add(57.98f);
ts1.add(99.65f);
ts.descendingIterator().forEachRemaining(s -> System.out.println(s));
boolean b = ts.descendingIterator().hasNext();
System.out.println(b);
Iterator<Float> i = ts.descendingIterator();
while (i.hasNext()) {
System.out.println(i.next());
System.out.println("");
Iterator<Float> j = ts1.descendingIterator();
try {
while (i.hasNext() && j.hasNext()) {
float comparison = j.next().compareTo(i.next());
System.out.println(comparison);
}
} catch (Exception e) {
System.out.println("Exception");
}
}
}
}