vendredi 13 juillet 2018

Java: Shorter way of checking several arguments to same value in a if-statement?

Is there an easy way to compare several arguments to the same value? To exemplify what I mean I have written this code which doesn't work, but illustrates what I'm looking for:

if ((arg1 && arg2 && arg3) > 0)

Instead of needing to write:

if (arg1 > 0 && arg2 > 0 && arg3 > 0)

Benefits would, in my opinion, be easier to read the code, and only needing to change one value.

Thanks.

Aucun commentaire:

Enregistrer un commentaire