

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get floor key from NavigableMap in Java
To get floor key means to return the greatest key less than or equal to the given key, or null if there is no such key. This can be done with the floorKey() metho.
The following is an example to get floor key from NavigableMap
Example
import java.util.*; public class Demo { public static void main(String[] args) { NavigableMap<String, Integer> n = new TreeMap<String, Integer>(); n.put("A", 498); n.put("B", 389); n.put("C", 868); n.put("D", 988); n.put("E", 686); n.put("F", 888); n.put("G", 999); n.put("H", 444); n.put("I", 555); n.put("J", 666); System.out.println("NavigableMap elements... "+n); System.out.println("Floor Key = "+n.floorKey("C")); } }
Output
NavigableMap elements... {A=498, B=389, C=868, D=988, E=686, F=888, G=999, H=444, I=555, J=666} Floor Key = C
- Related Questions & Answers
- Get first key from NavigableMap in Java
- Get last key from NavigableMap in Java
- Get ceiling key from NavigableMap in Java
- Get higher key from NavigableMap in Java
- Get lower key from NavigableMap in Java
- Get navigable key set in java from NavigableMap
- Get first entry from NavigableMap in Java
- Get last entry from NavigableMap in Java
- Create NavigableMap from TreeMap in Java
- Get the count of NavigableMap in Java
- Remove all elements from Java NavigableMap
- Get key from value in JavaScript
- Create NavigableMap in Java
- Get floor value of a number using Math.floor in Java
- Java Program to Get key from HashMap using the value
Advertisements