我正在尝试在浮点数组中引入一组浮点数:
protected float[] a = new float [100];
public void setCoef(){
System.out.println("Introduceti coeficientii: ");
for (int i = 0; i <= this.grad; i++)
{
Scanner in = new Scanner(System.in);
this.a[i] = in.nextFloat();
}
}
但是当我输入 2.3 时它会产生这个异常,例如:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextFloat(Scanner.java:2388)
at polinom.PolinomR.setCoef(PolinomR.java:35)
at polinom.PolinomReal.grade_coef(PolinomReal.java:14)
at polinom.Operatii.main(Operatii.java:43)