Groovy – size()

  • Post author:
  • Post category:Groovy
  • Post comments:0 Comments
number of elements

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

Previous Page:-Click Here

Leave a Reply