java.util.TreeMap.keySet() Method

Description

ThekeySet() method is used to return a Set view of the keys contained in this map. The set's iterator returns the keys in ascending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.

Declaration

Following is the declaration for java.util.TreeMap.keySet() method.

public Set<K> keySet()

Parameters

NA

Return Value

The method call returns a set view of the keys contained in this map.

Exception

NA

Example

The following example shows the usage of java.util.TreeMap.keySet() method.