我想調用一個方法來計算java中的平均值。但是,當我編譯它總是輸出'.class' expected
當它來到線: System.out.println(「Average:」+ Average(double Value []));java錯誤「.class expected」
這裏是我的代碼:
public class q2
{
public static void main(String[] args) throws IOException
{
new q2().InputValue();
}
public void InputValue() throws IOException
{
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
double[] Value = new double[10];
for (int i = 0; i < 10; i++)
{
System.out.println("Please enter a value: ");
Value[i] = Double.parseDouble(br.readLine());
}
System.out.println("Average: " + Average(double Value[]));
}
public double Average(double Value[])
{
double average = 0;
for (int n = 0; n < 10; n++)
{
average = average + Value[n];
}
average = average/10;
return average;
}
}
感謝
你真的這麼叫:Average(double Value [])? 這是錯字嗎? – Reddy 2010-11-26 14:00:32