Elegant way to code if (10 < x < 20)

Posted by Danny King on Stack Overflow See other posts from Stack Overflow or by Danny King
Published on 2010-04-12T18:29:32Z Indexed on 2010/04/12 18:32 UTC
Read the original article Hit count: 278

Filed under:

Hi,

Is there an elegant way in Java to code:

if (10 < x < 20) {
   ...
}

i.e. "if x is between 10 and 20"

rather than having to write

if ((x > 10) && (x < 20)) {
   ...
}

Thanks!

© Stack Overflow or respective owner

Related posts about java