code: private int rangeCheck(int value, int begin, int end) {
          if (value >= begin && value <= end) { // (begin,end]
              return value;
          }
  
          throw new IllegalArgumentException("Value [" + value + "] not in range [" + begin + "," + end + "]");
      }
docs: /*
  Convenience function to check integer boundaries. Checks if a value x is in the range [begin,end]. Returns x if it is in
  range, throws an exception otherwise.