选择语句的使用

来源:互联网 发布:梦幻西游2mac更新失败 编辑:程序博客网 时间:2024/05/21 06:57
/*选择语句:1、if 单分支选择语句2、if else 二分支选择语句3、if    else if 多分只选择语句4、switch ( 开关语句)三个关键字 switch case default 5*/class  Month{public static void main(String[] args) {int x=5;System.out.println("Hello java!");/*if (3<=x||x<=5){System.out.println(x+"春季");}else if(6<=x||x<=8)System.out.println(x+"夏季");else  if(9<=x||x<=11)System.out.println(x+"秋季");else System.out.println(x+"冬季");switch (x){default:System.out.println(x+"冬季");case 3 :case 4 :case 5 :System.out.println(x+"春季");break ;case 6 :case 7 :case 8 :System.out.println(x+"夏季");break ;case 9 :case 10 :case 11 :System.out.println(x+"秋季");break ;}*/}}