Hello, I have been reading the Assertion notes at:
http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html In the section on Preconditions, the following statements are made:
Do not use assertions to check the parameters of a public method. An assert is inappropriate because the method guarantees that it will always enforce the argument checks. It must check its arguments whether or not assertions are enabled.
It then goes on to say:
You can, however, use an assertion to
test a nonpublic method's precondition that you believe will be true no matter what a client does with the class.
Can someone please clarify this issue. I am confused as to how a public method can "guarantee
it will always enforce argument checks". In what way are the arguments checked?
Thanks!