博客
关于我
教妹学Java(十四):switch 语句详解
阅读量:107 次
发布时间:2019-02-25

本文共 2530 字,大约阅读时间需要 8 分钟。

?????Java???switch????

????????????????????????????????????????????????????Java??????????switch???

?????????????"switch??"????

???????????Java??switch????????????????????????????byte?short?int?long????????????Byte?Short?Integer??

????????????switch?????????

?????switch????????????????????????????????if-else?????????????????????????

?????????????????????C++??Python?if-else??????????switch???Java?????????

????????switch?????????Java??switch?????????????????????????????????????????????????

??????????????????????switch????

????????????????????????????????

int num = 5;switch (num) {case 1:System.out.println("?");break;case 2:System.out.println("?");break;default:System.out.println("??");break;}

???????????????if-else????????

???????????????????????switch?????????????????????????switch???????????if-else?????????????????????????????????

???????????switch????

??????????????????????????????switch?????????????????????????????????switch??????????????

???????????switch????????????????

????????????switch???case?????????????????????????case???????????????????

?????????????????????

?????????????????????case??????????

int num = 2;switch (num) {case 1:System.out.println("?");break;case 2:System.out.println("??");break;}

?????????????????????

??????????????????????????????switch????if-else????

?????????????????????????????????????????switch?????????????????????????switch??????

?????????????????????????????

????????????if-else???????????switch??????????????????

????switch?????????????????

??????????????????????????switch???case????????????case?????????????????????????

???????????????

???????????????????case????????

int num = 3;switch (num) {case 1 + 2:System.out.println("?");break;}

???????????case????????

???????????????????switch????

??????????switch????????????????????????????????case???????????switch???????????????????switch????if-else????????????????

????????????????switch????

????????????????????????????????????????

int month = 4;switch (month) {case 1:System.out.println("??");break;case 2:System.out.println("??");break;case 3:System.out.println("??");break;case 4:System.out.println("??");break;default:System.out.println("????");break;}

??????????????????????????????

????????switch??????????????????????????????????????????????switch???

??????????switch???if-else?????????

????????switch???????????????????????????switch??????????????if-else???????????????????????

?????????????switch??????????

???????????switch???????Java????????????????????????????switch??????????????????????switch???????????????????

转载地址:http://cg.baihongyu.com/

你可能感兴趣的文章
Python之OS模块进程管理介绍--os.fork()
查看>>
python之pandas详细分析(附代码)
查看>>
python之plt多图同框显示
查看>>
python之pyenv安装使用
查看>>
Python之random模块
查看>>
python之selenium访问网站被反爬限制封锁解决方法
查看>>
python之set函数
查看>>
python之virtualenv多环境管理
查看>>
python之web框架(2):了解WSGI接口
查看>>
Python之上下文管理
查看>>
python之元组
查看>>
python之元组
查看>>
Python之列表和元组
查看>>
python之判断一个值是不是可以被调用
查看>>
python之处理excel表格
查看>>
python之字符串【str】
查看>>
Python之并发请求 (干货)
查看>>
python之异常处理
查看>>
python之异常处理
查看>>
Python之杨辉三角算法实现
查看>>