Java字节码浅析(三)循环语句

来源:互联网 发布:二次型化为矩阵 编辑:程序博客网 时间:2024/06/11 23:42

点击打开链接

jdk 7版本开始,在switch,,.case 中才支持字符串格式,在此之前的版本只能是整型或者可以转换为整型的数值类型,比如byte、short、int、char、还有枚举.

public int simpleSwitch(String stringOne) {    switch (stringOne) {        case "a":            return 0;        case "b":            return 2;        case "c":            return 3;        default:            return 4;    }}


0 0
原创粉丝点击