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
No. You cannot do this,
switch (age){ case (>79): // Do this stuff break; case (>50): // Do this other stuff break; }
You need an if and else,
if
else
if (age > 79) { // do this stuff. } else if (age > 50) { // do this other stuff. } // ...