Check if int is between two numbers

后端 未结 10 1060
夕颜
夕颜 2020-11-28 13:09

Why can\'t do you this if you try to find out whether an int is between to numbers:

if(10 < x < 20)

Instead of it, you\'ll have to do

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 14:01

    The inconvenience of typing 10 < x && x < 20 is minimal compared to the increase in language complexity if one would allow 10 < x < 20, so the designers of the Java language decided against supporting it.

提交回复
热议问题