A SortedMap is a map that maintains its entries in ascending order, sorted
according to the
keys' natural order, or according to a Comparator
provided at SortedMap creation time. (Natural order and
Comparators are discussed in the section on Object Ordering In addition to the normal
Map operations, the Map interface provides
operations for:
Comparator used to
sort the map (if any).
Here is the code of program :
import java.util.*;
|
Output:
| The highest key value is: 5
All key value is: {1=One, 2=Two, 3=Three, 4=Four, 5=Five} The head map is: {1=One, 2=Two, 3=Three} The tail map is: {4=Four, 5=Five} key : 1 value :One key : 2 value :Two key : 3 value :Three key : 4 value :Four key : 5 value :Five |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: SortedMap (interface) example in java Collection Framework View All Comments
Post your Comment