CHAPTER 8
METHODS
228
(Item 74). Typically, the resulting exception will be
IllegalArgumentException
,
IndexOutOfBoundsException
, or
NullPointerException
(Item 72). Once
you’ve documented the restrictions on a method’s parameters and you’ve docu-
mented the exceptions that will be thrown if these restrictions are violated, it is a
simple matter to enforce the restrictions. Here’s a typical example:
/**
* Returns a BigInteger whose value is (this mod m). This method
* differs from the remainder method in that it always returns a
* non-negative BigInteger.
*
* @param m the modulus, which must be positive
* @return this mod m
*
Do'stlaringiz bilan baham: