I am referring to this post: What does the Java assert keyword do, and when should it be used?
My understanding is that: assertion helps check the validity of an variable, if the check fails, it throws an AssertionError
. And this check is usually turned off in production.
Question 1: Why in production we do not need to check validity of parameter? I mean, the user can pass in an invalid parameter to purposely break the program, right?
Question 2: Since assertion is usually turn off in production, does it mean I need to write check and throw exception in addition to the assertion?