Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: incorrect subtitle

...

Code Block
bgColor#ccccff
class CastAway {
  public static void workWith(int i) throws ArithmeticException {
    // check if i is within byte range
    if ((i < Byte.MIN_VALUE) || (i > Byte.MAX_VALUE)) { 
      throw new ArithmeticException("Value is out of range");
    }

    byte b = (byte) i;
    // work with b
  } 
}

Noncompliant Code Example (Floating-Point

...

to

...

Integer Conversion)

The narrowing primitive conversions in this noncompliant code example suffer from loss in the magnitude of the numeric value as well as a loss of precision.

...