Groovy - size()


Advertisements

Obtains the number of elements in this List.

Syntax

int size()

Parameters

None

Return Value

The size of the list.

Example

Following is an example of the usage of this method −

class Example {
   static void main(String[] args) {
      def lst = [11, 12, 13, 14];
      println(lst.size);
   } 
}

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

4
groovy_lists.htm
Advertisements