当我运行这个程序时,我在线程“main”java.lang.NumberFormatException 中得到错误异常:空字符串。是否可以通过以某种方式或必须使用 try catch 语句抛出异常来完成这项工作?
private double[] scores3 = new double[5];
Scanner keyboard = new Scanner(System.in);
public void enterData()
{
double score;
double numberMin = 0;
double numberMax = 100;
do{
System.out.println("Enter the student's third test score");
while (!keyboard.hasNextDouble()) {
keyboard.next();
}
score3 = keyboard.nextDouble();
}
while (score3 <= numberMin || score3 >= numberMax);
double score3 = Double.parseDouble(keyboard.nextLine());