Groovy – keySet()

  • Post author:
  • Post category:Groovy
  • Post comments:0 Comments
Keys

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]

Previous Page:-Click Here

Leave a Reply