What is the TreeMap class?
November 24th, 2006 by uCertify
Leave a reply »
The TreeMap class implements the NavigableMap and SortedMap interfaces. The operations on sorted maps rely on the natural ordering of the keys. The TreeMap class provides an implementation that sorts its entries in a specific order. Its implementation uses balanced trees, which deliver excellent performance for all operations. This class guarantees that the map will be in ascending key order, sorted according to the natural order for the key’s class, or by the comparator provided at creation time. The following are the constructors of TreeMap:
TreeMap(): It constructs a new, empty tree map using the natural ordering of its keys.
TreeMap(Comparator<? super K> comparator): It constructs a new, empty tree map, ordered according to the given comparator.
TreeMap(Map<? extends K,? extends V> m): It constructs a new tree map containing the same mappings as the given map, ordered according to the natural ordering of its keys.
TreeMap(SortedMap m): It constructs a new tree map containing the same mappings and using the same ordering as the specified sorted map.
Click here to get free scjp-5-0 SCJP 5/6 exam practice questions.
Best exam simulation SUN CX310-065 download free trial.
Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.