我需要帮助将相同的数组与自身相乘(将其平方)。我试图复制它,并创建一个新的数组,但我仍然遇到不兼容类型的错误。该错误突出显示了不同类型的radius1。将阵列与自身相乘
public static double[] part1(double[] z, double[] radius,double [] radius1)
{
for(int index=0; index <10; index++)
{
z= radius[index]*radius1[index];
}
// The formula to calculate gravity is:
// 6.67E-11 times the massOfPlanet divided by the radius of the planet squared
return z;
}
public static void main(String[] args)throws IOException
{
double[] radius = {2439.7, 6051.9, 6378, 3402.5, 71492, 60270, 25562, 24774, 1195};
double[] radius1 = {2439.7, 6051.9, 6378, 3402.5, 71492, 60270, 25562, 24774, 1195};
double z[]= new double [9];
}