|
Enabling Assertion
By default assertion are not enabled, but compiler complains if
assert is used as an identifier or label. The following command
will compile AssertionDemo with assertion enabled.
javac –source 1.4 AssertionDemo.java
The resulting AssertionDemo class file will contain assertion code.
By default assertion are disabled in Java runtime environment.
The argument –eanbleassertion or –ea will enables assertion,
while –disableassertion or –da will disable assertions
at runtime.
The following command will run AssertionDemo with assertion enabled.
Java –ea AssertionDemo
or
Java –enableassertion AssertionDemo
|