我是java初学者,我生成随机和的代码引发了一个奇怪的异常......
public void randomRekensom(int n)
{
switch(n) {
case 1: this.max = 100;
break;
case 2: this.max = 150;
break;
case 3: this.max = 200;
break;
}
getal1= (int) Math.sqrt(max);
getal2= (int) Math.sqrt(max);
operator=ThreadLocalRandom.current().nextInt(1, 4 + 1);
switch(operator) {
case 1: antwoord=(this.getal1+this.getal2);
operatorTeken=" + ";
break;
case 2: antwoord=(this.getal1-this.getal2);
operatorTeken=" - ";
break;
case 3: antwoord=(this.getal1/this.getal2);
operatorTeken=" / ";
break;
case 4: antwoord=(this.getal1*this.getal2);
operatorTeken=" * ";
break;
}
}
也许是因为我今天盯着屏幕看太多了,但我不知道为什么会出现这个错误。
提前致谢!