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