lundi 10 août 2015

Java - Concise if statement

I really don't know what should be the title of this question, spent 10 minutes but this is the best I came up with.

The real question is very basic and I think I know the answer. But still, like the operator condition ? true-statement : false-statement, is there any shortcut of this kind of if statement?

    if(intA == -1 || intB == -1 || intC == -1 || intD == -1 || intE == -1)

Suggestion: Something like this could be added in Java:

    if((intA || intB || intC || intD || intE) == -1)

Aucun commentaire:

Enregistrer un commentaire