Combine return and switch

后端 未结 12 2059
长情又很酷
长情又很酷 2021-02-03 22:15

How can I combine return and switch case statements?

I want something like

return switch(a)
       {
          case 1:\"lalala         


        
12条回答
  •  太阳男子
    2021-02-03 22:36

    public String doStaff(int a) {
    
       switch(a)
           {
              case 1: return "lalala"
              case 2: return "blalbla"
              case 3: return "lolollo"
              default: return "default" 
           };
    }
    

提交回复
热议问题