- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create NavigableMap from TreeMap in Java
To create NavigableMap from TreeMap. The following is the declaration −
NavigableMap<String, Integer> n = new TreeMap<String, Integer>();
Now, add some elements to the NavigableMap created above −
n.put("A", 888); n.put("B", 999); n.put("C", 444); n.put("D", 555); n.put("E", 666); n.put("F", 888); n.put("G", 999); n.put("H", 444); n.put("I", 555); n.put("J", 666);
The following is an example to create NavigableMap from TreeMap and display it −
Example
import java.util.*; public class Demo { public static void main(String[] args) { NavigableMap<String, Integer> n = new TreeMap<String, Integer>(); n.put("A", 888); n.put("B", 999); n.put("C", 444); n.put("D", 555); n.put("E", 666); 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); } }
Output
NavigableMap elements... {A=888, B=999, C=444, D=555, E=666, F=888, G=999, H=444, I=555, J=666}
- Related Articles
- Create NavigableMap in Java
- Get lower key from NavigableMap in Java
- Get floor key from NavigableMap in Java
- Get first key from NavigableMap in Java
- Get first entry 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 last entry from NavigableMap in Java
- Remove all elements from Java NavigableMap
- Get Sub Map from TreeMap in Java
- Remove all values from TreeMap in Java
- Get Tail Map from TreeMap in Java
- Get Head Map from TreeMap in Java
- Remove a value from TreeMap in Java

Advertisements