java二维数组的元素为【50-150】之间的随机整数求和
时间: 2023-05-11 22:02:58 浏览: 121
您好,以下是Java二维数组元素为【50-150】之间的随机整数求和的代码:
```
import java.util.Random;
public class Main {
public static void main(String[] args) {
int[][] arr = new int[5][5];
Random random = new Random();
int sum = 0;
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
arr[i][j] = random.nextInt(101) + 50;
sum += arr[i][j];
}
}
System.out.println("二维数组元素为【50-150】之间的随机整数求和为:" + sum);
}
}
```
希望能够帮到您!
阅读全文