本帖最后由 snowtscx 于 2010-01-29 17:04:45 编辑

解决方案 »

  1.   

    不能这样写的,判断条件有的是int型的,有的是boolean,怎么可以呢?
    老老实实多写几个case :break吧。
      

  2.   

    case 9||8:
            info="b";
            break;
    换成:
    case 9:
    case 8:
        info = "b";
        break;其他类似。
      

  3.   


    public class SwitchTest { /**
     * @param args
     */
    public static void main(String[] args) {
    for (int i = 1; i <= 10; i++) {
    System.out.println(i+":"+FunSwitch(i));
    }
    } private static String FunSwitch(int i){
    String info = "";

    switch (i) {
    case 10:
    info = "a";
    break;
    case 9:
    case 8:
    info = "b";
    break;
    case 7:
    case 6:
    case 5:
    case 4:
    case 3:
    case 2:
    case 1:
    info = "c";
    break;
    default:
    break;
    }

    return info;
    }
    }
    返回:
    1:c
    2:c
    3:c
    4:c
    5:c
    6:c
    7:c
    8:b
    9:b
    10:a
      

  4.   


    switch(score){    case 9:
        case 8:
            info="b";
            break;}
      

  5.   

    按5楼的方法不行吧,如果不行那只有写if语句 或 老老实实多写几个case :break吧。