Skip to content

Commit 043432d

Browse files
Add files via upload
1 parent 2bb4b02 commit 043432d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

NavigableMap17.java

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.NavigableMap;
2+
import java.util.TreeMap;
3+
4+
public class NavigableMap17 {
5+
//SubMap( fromKey:Key, boolean fromInclusive:true/false, toKey:Key, boolean toInclusive:true/false)
6+
public static void main(String[] args) throws Exception {
7+
NavigableMap<Float, Integer> map = new TreeMap<>();
8+
map.put(1.8f,11 );
9+
map.put(2.6f, 9);
10+
map.put(3.4f, 78);
11+
map.put(4.3f, 5);
12+
map.put(5.6f, 1);
13+
map.put(6.8f, 3);
14+
System.out.println("Map:" + map);
15+
System.out.println("SubMap:" + map.subMap(3.4f, true, 5.6f, true));
16+
// Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, inclusive.
17+
System.out.println("SubMap:" + map.subMap(3.4f, false, 5.6f, false));
18+
// Returns a view of the portion of this map whose keys range from fromKey, exclusive, to toKey, exclusive.
19+
System.out.println("SubMap:" + map.subMap(3.4f, true, 5.6f, false));
20+
// Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
21+
System.out.println("SubMap:" + map.subMap(3.4f, false, 5.6f, true));
22+
// Returns a view of the portion of this map whose keys range from fromKey, exclusive, to toKey, inclusive.
23+
}
24+
}

0 commit comments

Comments
 (0)