gpt4 book ai didi

java - 我不断收到编译器错误,说 Rainfallmain.java :13: error: expected.

转载 作者:行者123 更新时间:2023-11-30 02:52:06 25 4
gpt4 key购买 nike

我不知道为什么,编译器错误指向字符串数组。我应该创建一个 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"

成员访问运算符 . 后面需要跟一个标识符(正在访问的成员的名称),而不是字符串文字。这就是为什么错误消息显示“需要标识符”。

您可能想在那里使用逗号。

关于java - 我不断收到编译器错误,说 Rainfallmain.java :13: error: <identifier> expected.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38315924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com