local numbers = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) -- 计算所有元素的索引加权和 local weightedSum = numbers:foldIndexed(0, function(index, acc, element) return acc + element * (index + 1) end) -- 输出:索引加权和: 55 _console:log("索引加权和: ", weightedSum)