Groovy - size()



返回此範圍中的元素數量。

語法

int size()

引數

返回值

返回範圍的大小。

以下是使用方法的示例 -

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

當我們執行以上程式時,我們將獲得以下結果 -

10
groovy_ranges.htm
廣告
© . All rights reserved.