If you use assertions in your code, you must compile with the option -source 1.4,(1.3 is the default), and execute with the option -enableassertions (or -ea).
The syntax is very simple. The basic assertion statement is:
assert boolean_expression;
If boolean_expression evaluates to false, the program will terminate by throwing an AssertionError exception.
You can also use the form:
assert boolean_expression : expression;
where expression can be an expression of any type but typically will be a
String object. If boolean expression is false an exception of type AssertionError is thrown, but this time the result of evaluating expression will be passed to the AssertionError constructor(there are constructors for all the primitive types plus Object).
Basically the effect of an assertion is the same as in C++.