Specifications

Sun Services
Java™ Programming Language
Module 8, slide 21 of 25
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Recommended Uses of Assertions
Use assertions to document and verify the assumptions and
internal logic of a single method:
Internal invariants
Control flow invariants
Postconditions and class invariants
Inappropriate Uses of Assertions
Do not use assertions to check the parameters of a
public method.
Do not use methods in the assertion check that can
cause side-effects.