Can you use conditional statements in switch-case in Android?

前端 未结 7 1120
梦毁少年i
梦毁少年i 2021-02-09 16:07

I can\'t seem to find a straight forward yes or no to this in my searching. In Android, is there a way to use a conditional statement in case-switch? For example, with age being

7条回答
  •  你的背包
    2021-02-09 16:40

    If you are using a loop you might want to look at What is the "continue" keyword and how does it work in Java?. This is not a good place to use switch.

    if(age > 79)
    {
       //do stuff
       continue; // STOP FLOW HERE AND CONTINUE THE LOOP
    }
    else if(age > 50)
    {
       //do stuff
       continue; // STOP FLOW HERE AND CONTINUE THE LOOP
    }
    

提交回复
热议问题