返回此范圍中指定位置處的元素。
Object get(int index)
索引 - 從范圍中獲取的索引值。
特定索引處的范圍值。
下面是一個(gè)使用這個(gè)方法的例子 -
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)); } }
當(dāng)我們運(yùn)行上面的程序,我們將得到以下結(jié)果 -
3 5
更多建議: