相关代码 |
|
/* *文件名 ex_3_2_3.java *说 明:演示if-else-if阶梯 */ class ex_3_2_3 { public static void main(String args[]) { int month = 4; // 四月 String season; if(month == 12 || month == 1 || month == 2) season = "冬天"; else if(month == 3 || month == 4 || month == 5) season = "春天"; else if(month == 6 || month == 7 || month == 8) season = "夏天"; else if(month == 9 || month == 10 || month == 11) season = "秋天"; else season = "不存在的月份"; System.out.println("四月是" + season + "."); } }
相关资源 |
|