if-else structure

Posted by Halo on Stack Overflow See other posts from Stack Overflow or by Halo
Published on 2010-04-07T07:12:47Z Indexed on 2010/04/07 7:23 UTC
Read the original article Hit count: 249

Filed under:
|

I have these long statements that I will refer to as x,y etc. here. My conditional statements' structure goes like this:

if(x || y || z || q){
    if(x)
       do someth
    else if (y)
       do something

    if(z)
       do something
    else if(q)
       do something
}
else
    do smthing

Is there a better, shorter way to write this thing? Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about if-else-statement