-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTreeSetDemo7.java
More file actions
21 lines (20 loc) · 776 Bytes
/
Copy pathTreeSetDemo7.java
File metadata and controls
21 lines (20 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package TreeSet;
import java.util.TreeSet;
public class TreeSetDemo7 {
public static void main(String[] args) {
// Create a TreeSet of String objects.
TreeSet<Float> ts = 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);
TreeSet<Float> ts1 = new TreeSet<>();
ts1.addAll(ts.subSet(20.78f, true, 60.65f, true));
System.out.println("(Sub Set)Elements in the range 20.78 to 40.78 are:" + ts1);
System.out.println(ts.subSet(20.78f,true, 40.78f,true));
System.out.println(ts.subSet(20.78f, false, 40.78f, true));
System.out.println(ts.subSet(20.78f, true, 40.78f, false));
}
}