Java ошибка в коде java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
Вот этот код выдает ошибку, а тут даже массива нет
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
Не могу понять что делать
static public void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double a = scanner.nextDouble();
double b = scanner.nextDouble();
double c = scanner.nextDouble();
double d = (b * b) - (4 * a * c);
if (d < 0)
{
System.out.println("no roots");
}
else
{
double x1 = (-1 * b + Math.sqrt(d))/(2 * a);
System.out.println(x1);
if (d > 0) {
// вот этот кусок выдает ошибку
double x2 = (-1 * b - Math.sqrt(d))/(2 * a);
System.out.println(x2);
}
}