【发布时间】:2017-11-17 23:47:07
【问题描述】:
我只需要使用嵌套的 while 循环来填充用户输入的双精度数组。这是我目前所拥有的:
public static double[][] score() {
int col = 3;
int row = 3;
int size = 0;
Scanner in = new Scanner(System.in);
double[][] scores = new double[row][col];
System.out.println("Enter your scores: ");
while (in.hasNextDouble() && size < scores.length) {
while (size < scores[size].length) {
scores[][] = in.hasNextDouble();
size++;
}
return scores;
}
【问题讨论】:
-
你事先知道数组的大小吗?
-
3 行 3 列,所以我总共需要 9 个输入。
标签: java arrays loops while-loop