Claims are not enabled by default, you need to pass the -ea to the JVM to enable them. Therefore, in many cases, this can be a simple omission to deploy. Other reasons may be productive (I have no evidence that the statements will noticeably slow down) or the correct handling of errors, i.e. It may be considered inappropriate for the production system to choose AssertionError live.
Confirming the arguments of a private method is appropriate because you must have full control over the arguments passed to them. OTOH public methods are called from the outside world, so you can’t control the specific arguments passed, so it’s better to explicitly check the arguments and handle the wrong arguments accordingly (for example, throwing a suitable exception at runtime, such as IllegalArgumentException ), or for null references, let JVM throws a NullPointerException .
source share