Java Reference
In-Depth Information
347
Modifying an Object Reference Parameter Has No Effect on the Caller
8.5 Preconditions and Postconditions
A precondition is a requirement that the caller of a method must obey. For example,
the deposit method of the BankAccount class has a precondition that the
amount to be deposited should not be negative. It is the responsibility of the caller
never to call a method if one of its preconditions is violated. If the method is called
anyway, it is not responsible for producing a correct result.
A precondition is a requirement that the caller of a method must meet. If a method
is called in violation of a precondition, the method is not responsible for
computing the correct result.
Search WWH ::




Custom Search