...
Code Block | ||
---|---|---|
| ||
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
}
}
|
...