沒(méi)發(fā)現(xiàn)大括號(hào)那有問(wèn)題呢,請(qǐng)大家?guī)兔χ赋鰜?lái)
public?class?Application?{ ????public?static?void?main(String[]?args)?{ ????????//給出備選菜單,采集用戶輸入 ????????System.out.println("查詢最近天氣預(yù)報(bào)"); ????????System.out.println("輸入1,未來(lái)24小時(shí)天氣預(yù)報(bào)"); ????????System.out.println("輸入2,未來(lái)3天天氣預(yù)報(bào)"); ????????System.out.println("輸入3,未來(lái)7天天氣預(yù)報(bào)"); ????????System.out.print("請(qǐng)輸入您的選擇:"); ????????//接收用戶輸入信息?Scanner ????????Scanner?scanner?=?new?Scanner(System.in); ????????int?i?=?scanner.nextInt(); ????????System.out.println("請(qǐng)輸入數(shù)字"?+?i); ????????//進(jìn)行判斷 ????????if(i?==?1){ ????????????System.out.println("請(qǐng)輸入城市名稱:"); ????????????String?city?=?scanner.next(); ????????????//接口weatherutils實(shí)例化 ????????????WeatherUtils?weatherUtils?=?new?WeatherUtilsImpl(); ????????????List<HourWeather>?list?=?weatherUtils.w24h("acbfa8f57a4b4b9cbe59d86c38ec6db2",city); ????????????System.out.println(list); ????????????//格式化判斷輸出 ????????????if(list.size()?==?0){ ????????????????System.out.println("沒(méi)有查詢到您輸入城市的天氣信息"); ????????????}else?{ ????????????????//如果list.size()不等于0?則對(duì)HourWeather數(shù)據(jù)進(jìn)行遍歷 ????????????????for(HourWeather?hourWeather:list){ ????????????????????//定義一個(gè)格式化模板 ????????????????????String?template?=?"%s月%s日%s時(shí)?|?%-4s?|?%-20s?|?%-8s?|?%-4s攝氏度?"; ????????????????????//返回字符串row,代表一行數(shù)據(jù) ????????????????????String?row?=?String.format(template,new?String[]?{ ????????????????????hourWeather.getMonth(); ????????????????????hourWeather.getDay(); ????????????????????hourWeather.getHour(); ????????????????????hourWeather.getWindDirection(); ????????????????????hourWeather.getWindPower(); ????????????????????hourWeather.getWeather(); ????????????????????hourWeather.getTemperature(); ????????????????????}); ????????????????????//將row數(shù)據(jù)打印輸出 ????????????????????System.out.println(row); ????????????????} ????????????} ????????}else?if(i?==?2){ ????????} ????} }
報(bào)錯(cuò)信息:
D:\weather\src\com\zhang\weather\Application.java:44:43
java: 需要'}'
2021-12-06
我發(fā)現(xiàn)問(wèn)題了,錯(cuò)誤的把每個(gè)元素的get方法后面用了分號(hào)