Java:运算符 - 对于参数类型 double、double[] 未定义

Java: The operator - is undefined for the argument types double, double[]

错误 "the operator - is undefined for the argument types double[], double" 在以下方法中不断出现,我不知道为什么或如何修复它。

   public static double inputstartX (double targetX[])throws IOException{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Please enter the horizontal starting point");
            while (true){
                try {
                    double x = Double.parseDouble(br.readLine());
                    if ((targetX-x)<=500 && (targetX-x)>=50){
                        return x;
                    }
                    else {
                        System.out.println("The starting point must be at a horizontal distance between 50 to 500 meters away from the target");
                        System.out.println("Please enter the horizontal starting point again");
                    }
                }
                catch (NumberFormatException e){
                    System.out.println("Invalid Input, please try again");
                }
            }

具体在行: "if ((targetX-x)<=500 && (targetX-x)>=50){"

您正在尝试从数组中减去,这不是双精度数。
数组本身存储多个相同类型的值。
您需要调用其中一个,例如 targetX[0],它将给出第一个值。

或者,如果您认为 [] 是一个错误,请将其删除。

targetX 是双精度数组。这意味着您不能从中减去另一个 double。您首先必须指定数组中的一个元素。

示例:

targetX[0] -= x;
        ^
  index of element (in this case: 0)