posted 20 years ago
hai Lakshmi,
Arguments to a method are expected to be correct at all times and there is no point in asserting their validity by turning on the assertion facility.
If arguments to a method are found incorrect then exceptions are to be thrown at all times. What happens when you check the validity of arguments to a public method is that,
when an incorrect argument is passed, an Error(Assertion Error) is thrown only when the assertion facility is turned on. When the assertion facility is turned off, the incorrectness of the argument goes undetected.
The reason why this correctness rule applies only to public methods is that,
only public methods are exposed to the user and there is no point in enforcing this correctness rule for private methods, that wont be called outside your class.
RUF