Skip to content

Commit c7bf212

Browse files
Add files via upload
1 parent 2287fd8 commit c7bf212

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

NavigableMap6.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.NavigableMap;
2+
import java.util.TreeMap;
3+
4+
public class NavigableMap6 {
5+
//floorEntry
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("Floor Entry:" + map.floorEntry(3.0f));//3.0f is less than 3.4f and greater than 2.6f,hence returns 2.6f key-value pair(Floor Value).
16+
System.out.println("Floor Entry:" + map.floorEntry(3.4f));//3.4f is equal to 3.4f ,hence returns 3.4f key-value pair(If equal , it becomes Floor Value of itself).
17+
System.out.println("Floor Entry:" + map.floorEntry(3.5f));//3.5f is greater than 3.4f and less than 4.3f,hence returns 3.4f key-value pair(Floor Value).
18+
19+
}
20+
21+
}

0 commit comments

Comments
 (0)