为了账号安全,请及时绑定邮箱和手机立即绑定

没发现大括号那有问题呢,请大家帮忙指出来

public class Application {

    public static void main(String[] args) {
        //给出备选菜单,采集用户输入
        System.out.println("查询最近天气预报");
        System.out.println("输入1,未来24小时天气预报");
        System.out.println("输入2,未来3天天气预报");
        System.out.println("输入3,未来7天天气预报");
        System.out.print("请输入您的选择:");
        //接收用户输入信息 Scanner
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        System.out.println("请输入数字" + i);

        //进行判断
        if(i == 1){
            System.out.println("请输入城市名称:");
            String city = scanner.next();
            //接口weatherutils实例化
            WeatherUtils weatherUtils = new WeatherUtilsImpl();
            List<HourWeather> list = weatherUtils.w24h("acbfa8f57a4b4b9cbe59d86c38ec6db2",city);
            System.out.println(list);
            //格式化判断输出
            if(list.size() == 0){
                System.out.println("没有查询到您输入城市的天气信息");
            }else {
                //如果list.size()不等于0 则对HourWeather数据进行遍历
                for(HourWeather hourWeather:list){
                    //定义一个格式化模板
                    String template = "%s月%s日%s时 | %-4s | %-20s | %-8s | %-4s摄氏度 ";

                    //返回字符串row,代表一行数据
                    String row = String.format(template,new String[] {
                    hourWeather.getMonth();
                    hourWeather.getDay();
                    hourWeather.getHour();
                    hourWeather.getWindDirection();
                    hourWeather.getWindPower();
                    hourWeather.getWeather();
                    hourWeather.getTemperature();
                    });
                    //将row数据打印输出
                    System.out.println(row);

                }
            }


        }else if(i == 2){

        }
    }
}

报错信息:

D:\weather\src\com\zhang\weather\Application.java:44:43

java: 需要'}'


正在回答

1 回答

我发现问题了,错误的把每个元素的get方法后面用了分号

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第二季 升级版
  • 参与学习       529884    人
  • 解答问题       6086    个

课程升级!以终为始告别枯燥,在开发和重构中体会Java面向对象编程的奥妙

进入课程

没发现大括号那有问题呢,请大家帮忙指出来

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信