返回此范围中指定位置处的元素。
句法
- Object get(int index)
参数
索引 - 从范围中获取的索引值。
返回值
特定索引处的范围值。
例子
下面是一个使用这个方法的例子 -
- class Example {
- static void main(String[] args) {
- // Example of an Integer using def
- def rint = 1..10;
- println(rint.get(2));
- println(rint.get(4));
- }
- }
当我们运行上面的程序,我们将得到以下结果 -
- 3
- 5
转载本站内容时,请务必注明来自W3xue,违者必究。