[英]i keep getting a compiler error saying, Rainfallmain.java:13: error: <identifier> expected.
我不知道為什么,編譯器錯誤指向字符串Array。 我應該進行for循環並手動為每個下標填寫年份的月份名稱嗎? 請幫忙!!
import java.util.*;
public class Rainfallmain
{
public static void main(String [] args)
{
double months = 12;
double average = Rainfallyr.getAverage();
double Mostrain = Rainfallyr.getHighest();
double Leastrain = Rainfallyr.getLowest();
double total = Rainfallyr.getTotal();
double [] Rainfallyr = new Rainfall[months];
String[] Mon = {"January", "Febuary", "March", "April", "May", "June", "July", "August". "September", "October", "November", "December"};
getRainvalues(Rainfallyr, mon);
System.out.println(" The total rainfall for the year is " + Mostrain);
System.out.println(" The total least aount of rain is " + Leastrain);
System.out.println(" The total rainfall for the year is " + total);
System.out.println(" The average rainfall for the year is " + average);
}
}
public static void getAllvalues(double []rain, String [] mon)
{
Scanner input = new Scanner(System.in);
for(int i = 0; i < r.length; i++)
{
System.out.print(" Enter Rain for each month" +mon[i]+" :");
r[i] = input.nextDouble();
}
}
"August". "September"
成員訪問運算符.
需要后面跟一個標識符(正在訪問的成員的名稱),而不是字符串文字。 這就是錯誤消息顯示“期望的標識符”的原因。
您可能打算在其中使用逗號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.