书中的例题
源代码在线查看: example2_9.java
软件大小: |
10957 K |
上传用户: |
ydyzd_2008 |
|
|
关键词: |
|
下载地址: |
免注册下载 普通下载
|
|
/* if-else-if 结构. */
class Example2_9 {
public static void main(String args[]) {
int month = 4; // 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("4月是 " + season + ".");
}
}