Groovy - keySet()



Obtain a Set of the keys in this Map.

Syntax

Set keySet()

Parameters

None.

Return Value

Set of Keys.

Example

Following is an example of the usage of this method −

class Example { 
   static void main(String[] args) { 
      def mp = ["TopicName" : "Maps", "TopicDescription" : "Methods in Maps"] 
      println(mp.keySet()); 
   } 
}

When we run the above program, we will get the following result −

[TopicName, TopicDescription]
groovy_maps.htm
Advertisements