File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package TreeSet ;
2+
3+ import java .util .Iterator ;
4+ import java .util .TreeSet ;
5+
6+ public class TreeSetDemo14 {
7+
8+ public static void main (String [] args ) {
9+ TreeSet <Float > ts = new TreeSet <>();
10+ TreeSet <Float > ts1 = new TreeSet <>();
11+ ts .add (10.58f );
12+ ts .add (20.78f );
13+ ts .add (30.65f );
14+ ts .add (40.78f );
15+ ts .add (50.98f );
16+ ts .add (60.65f );
17+
18+ ts1 .add (10.55f );
19+ ts1 .add (25.88f );
20+ ts1 .add (34.65f );
21+ ts1 .add (45.78f );
22+ ts1 .add (57.98f );
23+ ts1 .add (99.65f );
24+ ts .descendingIterator ().forEachRemaining (s -> System .out .println (s ));
25+
26+ boolean b = ts .descendingIterator ().hasNext ();
27+ System .out .println (b );
28+
29+ Iterator <Float > i = ts .descendingIterator ();
30+ while (i .hasNext ()) {
31+ System .out .println (i .next ());
32+ System .out .println ("" );
33+ Iterator <Float > j = ts1 .descendingIterator ();
34+ try {
35+ while (i .hasNext () && j .hasNext ()) {
36+ float comparison = j .next ().compareTo (i .next ());
37+ System .out .println (comparison );
38+ }
39+ } catch (Exception e ) {
40+ System .out .println ("Exception" );
41+ }
42+
43+ }
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments