慕侠1366386
2022-04-25 21:02
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);
把最上面自动引用的的包删除了
Java入门第二季 升级版
530649 学习 · 6091 问题
相似问题