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

为什么我到输入城市的那一步就报错

package com.imooc.weather;

import com.imooc.weather.impl.WeatherUtilsImpl;
import sun.plugin.dom.exception.BrowserNotSupportedException;

import java.util.List;
import java.util.Scanner;

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= new Scanner(System.in);
        int i= scanner.nextInt();
        System.out.println("用户输入数字"+i);
        if (i==1){
            System.out.println("请输入城市名称查询为24小时天气预报");
            String city= scanner.next();
            WeatherUtils weatherUtils =new WeatherUtilsImpl();
            List<HourWeather> weatherList = weatherUtils.w24h("6196c9db162949e78158039af608da0c",city);//有问题
            System.out.println(weatherList);
            if (weatherList.size()==0){
                System.out.println("抱歉,未收录您查询的城市天气数据");
            }else {
                for (HourWeather hourWeather: weatherList){
                    String template= "%s月%s日%s时|%s|%s|%s|%s℃";
                    String row= String.format(template,new String[]{
                            hourWeather.getMonth(),
                            hourWeather.getDay(),
                            hourWeather.getHour(),
                            hourWeather.getWindDirection(),
                            hourWeather.getWindPower(),
                            hourWeather.getTemperature(),
                    });
                    System.out.println(row);


正在回答

1 回答

把最上面自动引用的的包删除了

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

举报

0/150
提交
取消

为什么我到输入城市的那一步就报错

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