Java Programming/Keywords/assert

is a Java keyword used to define an assert statement. An assert statement is used to declare an expected boolean condition in a program. If the program is running with assertions enabled, then the condition is checked at runtime. If the condition is false, the Java runtime system throws an AssertionError Assertions may be declared using the following syntax:

is a boolean that will throw the assertion if it is false. When it is thrown, the assertion error exception is created with the parameter  (if applicable).

An example:

Assertions are usually used as a debugging aid. They should not be used instead of validating arguments to public methods, or in place of a more precise runtime error exception.

Assertions are enabled with the Java  or  runtime option. See your Java environment documentation for additional options for controlling assertions.