public static void main(String[] args) {
int[] ints = new int[]{1, 2, 3, 4, 5};
Arrays.setAll(ints, new IntUnaryOperator() {
@Override
public int applyAsInt(int operand) {
// 每个数进行平方
return (ints[operand]) * (ints[operand]);
}
});
System.out.println(Arrays.toString(ints));
}





网友评论