博客
关于我
教妹学Java(十四):switch 语句详解
阅读量:105 次
发布时间: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/

你可能感兴趣的文章
Objective-C实现strongly Connected Components 强连通分量算法(附完整源码)
查看>>
Objective-C实现strschr函数功能(附完整源码)
查看>>
Objective-C实现subset generation子集生成算法(附完整源码)
查看>>
Objective-C实现substring函数功能(附完整源码)
查看>>
Objective-C实现SudokuSolver数独解决方案算法(附完整源码)
查看>>
Objective-C实现sum of arithmetic series算术级数之和算法(附完整源码)
查看>>
Objective-C实现sum of geometric progression几何级数之和算法(附完整源码)
查看>>
Objective-C实现sum of subset子集总和算法(附完整源码)
查看>>
Objective-C实现SVM支持向量机算法(附完整源码)
查看>>
Objective-C实现sylvester西尔维斯特方程算法(附完整源码)
查看>>
Objective-C实现tabu search禁忌搜索算法(附完整源码)
查看>>
Objective-C实现tanh函数功能(附完整源码)
查看>>
Objective-C实现Tarjan 用于在有向图中查找强连通分量的算法(附完整源码)
查看>>
Objective-C实现TCP Server 多线程同时连接多个客户端(附完整源码)
查看>>
Objective-C实现TCP拥塞控制(附完整源码)
查看>>
Objective-C实现tcp网络通讯服务器+客户端(附完整源码)
查看>>
Objective-C实现Tenengrad梯度函数(附完整源码)
查看>>
Objective-C实现ternary search三元搜索算法(附完整源码)
查看>>
Objective-C实现TernarySearch三分查找算法(附完整源码)
查看>>
Objective-C实现The Game of Life 生命游戏算法(附完整源码)
查看>>