问答详情
源自:4-6 Java条件语句之 switch

条件语句switch

这个语句怎么依次输出?一一对应,比如第一名奖励。。第二名奖励。。 


提问者:慕无忌5259836 2018-11-26 16:18

个回答

  • 鲜奶面包
    2018-12-11 20:06:34

    switch 后面小括号中表达式的值必须是整型或字符型

  • 鲜奶面包
    2018-12-11 20:05:57

    public class HelloWorld {
        public static void main(String[] args) {
      char today='日';
      switch(today){
           
            case '一':
                case '三':
                    case  '五':
                        System.out.println("早餐吃包子");break;
                        case '二':
                            case '四':
                                case '六':
                                    System.out.println("早餐吃油条");break;
                                    case '日':
                                        System.out.println("吃主席套餐");
                                        break;
                                        default :
                                        System.out.println("啥都不吃");
           

  • 慕斯8250619
    2018-11-26 17:26:53

    String Str="名次"

    switch(Str){

        case一:

            System.out.println("奖励为...");

            break;

        case二:

            System.out.println("奖励为...");

    }