Groovy - size()



Returns the number of elements in this Range.

Syntax

int size()

Parameters

None

Return Value

Returns the size of the range.

Following is an example of the usage of this method −

class Example { 
   static void main(String[] args) { 
      // Example of an Integer using def 
      def rint = 1..10; 
      println(rint.size()); 
   } 
}

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

10
groovy_ranges.htm
Advertisements