的
输入命令:
利用Scanner对象获取用户输入的数据。
适用方法:Scanner objectName = new Scanner(System.in);objectName.nextInt()/next()/nextDouble()。
换行输出:println;不换行输出:print。
List<HourWeather> weatherList = weatherUtils.w24h()
解释:因为w24h()方法返回的就是一个List类型的数据集合,所以,返回的数据集合可以实例化List<HourWeather> 的对象。
应用初体验 逆命名法,Application
package com.imooc.weather;
import com.imooc.weather.impl.WeatherUtilsImpl;
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.print("请输入城市名称查询未来24小时天气预报:");
String city = scanner.next();
WeatherUtils weatherUtils = new WeatherUtilsImpl();
List<HourWeather> weatherList = weatherUtils.w24h("6041b3aec1454b558067ffd7148e5b29",city);
System.out.println(weatherList);
}
}
}
IntelliJ的快捷键
psvm:生成main方法
sout:生成打印语句
jar包放在lib中
在设置中,project structure,libraries,+,Java,选择,OK
在 "" 中输入AppCode