Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Groovy map


May 14, 2021 Groovy



Maps (also known as associated arrays, dictionaries, tables, and hash) are out-of-order collections of object references. ue. he keys used in Map can be any class. W hen we insert into the Map collection, we need two values: the key and the value.

Here are some examples of mapping -

  • 'TopicName': 'Lists', 'TopicName': 'Maps' - A collection of key value pairs with TopicName as a key and its corresponding values.

  • - Empty mapping.

In this chapter, we'll discuss the mapping methods available in Groovy.

Serial number Method and description
1 containsKey()

Does this map contain this key?

2 get()

Look for the keys in this Map and return the appropriate value. I f there are no key entries in this map, null is returned.

3 keySet()

Gets a set of keys in this map.

4 put()

Associate the specified value with the specified key in this map. If this map previously contained a map of this key, the old value is replaced with the specified value.

5 size()

Returns the number of key value maps in this map.

6 values()

Returns a collection view of the values contained in this map.