使用伪局部变量int[] ref = {1};然后表达式对其操作
int[] ref = {1};
list.forEach(s -> {
ref[0] = ref[0] + 1;
});
本文介绍了如何在Java中使用伪局部变量int[]ref,并通过list.forEach()遍历时对数组进行操作,更新ref[0]的值。
使用伪局部变量int[] ref = {1};然后表达式对其操作
int[] ref = {1};
list.forEach(s -> {
ref[0] = ref[0] + 1;
});

被折叠的 条评论
为什么被折叠?