switch后的判断条件只能是简单变量,不能是引用变量
字符串是引用变量  整形是简单变量int a = integer.valueof(s)
自己测试

解决方案 »

  1.   

    switch后面只能跟三种变量:int,byte,char,
      

  2.   

    1.switch后面只能跟三种变量:int,byte,char
    2.int i = Integer.parseInt(s);
      

  3.   


    1.  switch(x) 中的 x 不能为 String 类型2.  怎样将 String s 强制转化为 int:
        String s = null;
        int k = Integer.parseInt(s); // 使用包装类
      

  4.   

    楼上的说的对!补充:short可以,long不行