what is treemap in java collection with examples
GIAN Tutorials
2:50 AM
TreeMap in java with examples TreeMap class implements Map similar to HashMap. Some important points about TreeMap: TreeMap implements Map interface and extends HashMap class. TreeMap is implemented using Red black tree based NavigableMap. TreeMap is ordered collection and store its elements in natural ordering of keys. Key which you would like to put in TreeMap must implement Comaparable interface or you can use Comparator for custom sorting Example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 package org . arpit . java2blog ; import java . util . TreeMap ; public class TreeMapMain { public static void main ( String args [ ] ) { // TreeMap with Country as key and capital as value // TreeMap stores elements in natural ordering of keys. TreeMap < String , String > co...