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

Java:运算符-对于参数类型double,double[]未定义,java,arrays,methods,double,Java,Arrays,Methods,Double,下面的方法中不断出现错误“参数类型double[],double的运算符-未定义”,我不知道为什么或如何修复它 public static double inputstartX (double targetX[])throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Pl

下面的方法中不断出现错误“参数类型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");
                }
            }
public static double-inputstartX(double-targetX[])抛出IOException{
BufferedReader br=新的BufferedReader(新的InputStreamReader(System.in));
System.out.println(“请输入水平起点”);
while(true){
试一试{
double x=double.parseDouble(br.readLine());
如果((targetX-x)=50){
返回x;
}
否则{
System.out.println(“起点必须位于距离目标50到500米之间的水平距离”);
System.out.println(“请再次输入水平起点”);
}
}
捕获(数字格式){
System.out.println(“输入无效,请重试”);
}
}
特别是在生产线上:
“如果((targetX-x)=50{”

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


或者,如果您认为
[]
是一个错误,只需删除它。

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

例如:

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

您正在尝试从数组中减去一个数字。