This helper method checks if a given number is in between the range of the two numbers. I tried using >= and <= but they did not work. This method did the trick. I forgot where I found this one. It was in a forum about Java.
|
1 2 3 |
public static boolean isInRange(int a, int b, int c) { return b > a ? c >= a && c <= b : c >= b && c <= a; } |