assert

The assert keyword, previously reserved for future use in JDK 1.3 and earlier, is used in the assertion facility in JDK 1.4.

An assertion is understood to be a statement containing a boolean expression that the programmer believes to be true at the time the statement is executed. For example, after unmarshalling all of the arguments from a data buffer, a programmer might assert that the number of bytes of data remaining in the buffer is zero. The system executes the assertion by evaluating the boolean expression and reporting an error if the expression evaluates to false. By verifying that the boolean expression is indeed true, the system corroborates the programmer's knowledge of the program thus increasing the possibility that the program is free of errors.

Assertion checking may be disabled for increased performance. Typically, assertion checking is enabled during program development and testing and disabled for deployment. Assertions are enabled and enabled at runtime.

To enable the assert keyword in JBuilder, choose Project|Project Properties, choose the General tab, and check the Enable Assert Keyword option.

See also