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

前端 未结 7 1143
梦毁少年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:30

    You can't do this use if then statement.

    if(age > 79)
    {
       //do stuff
    }
    else if(age > 50)
    {
       //do stuff
    }
    else
    {
       /do stuff
    }
    

    etc...

提交回复
热议问题