Check if int is between two numbers

后端 未结 10 1057
夕颜
夕颜 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 13:45

    simplifying:

    a = 10; b = 15; c = 20
    
    public static boolean check(int a, int b, int c) {
        return a<=b && b<=c;
    }
    

    This checks if b is between a and c

提交回复
热议问题