# encoding: utf-8 numbers = $objectWrappers.wrap($arrays.newArray($plugins.loadClass("java.lang.Long"), 5)) # 使用值 10 填充数组的索引0-3所有元素 numbers.fill(10, 0, 3) # 填充后的数组: [10, 10, 10, nil, nil] numbers.forEachIndexed { |index, element| $console.log(index, element) } # 创建一个大小为 5 的字符串数组,并使用 "hello" 填充 strings = $objectWrappers.wrap($arrays.newArray($plugins.loadClass("java.lang.String"), 5)) strings.fill("hello", 0, 3) # 字符串数组: [hello, hello, hello, nil, nil] strings.forEachIndexed { |index, element| $console.log(index, element) }