switch 语句的参数类型

switch(参数值){

    case value:

    [default://可选

    defaultStatements;

]

参数值类型必须是这几种类型之一:int,byte,char,short

switch为什么只能用int,short,byte,char,而不能用long,String呢?因为switch 只能使用 int 类型或者是可以转换为 int类型的参数(char,char 和 int 通过ascii转换)。

posted @ 2014-07-24 17:40  文少爷  阅读(879)  评论(0编辑  收藏  举报