code: private static int subAndCheck(final int x, final int y) {
          final long s = (long) x - (long) y;
          if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) {
              throw new ArithmeticException("overflow: add");
          }
          return (int) s;
      }
docs: Subtract two integers, checking for overflow.
  
  @param x
  the minuend
  @param y
  the subtrahend
  @return the difference <code>x-y</code>
  @throws ArithmeticException
  if the result can not be represented as an int