assert
Assertions tests conditions. If the conditions fails (result=false) an exceptions (AssertionError) is thrown.
Example 1:
public void doSomething(String str) { assert str != null; if (str.length > 0) ... }
Example 2 (with message text for the stacktrace):
public void doSomething(String str) { assert str != null : "Parameter must not be null"; if (str.length > 0) ... }
VM-Parameter for asserts:
-ea (enable assertions)
-ea:packagename
-da (disable assertions)
-da:packagename