Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
By default assertion is not enabled, but compiler complains if assert is used as an identifier or label. The following command will compile AssertionDemo example 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
<< Java Assertion Tutorial Second Form of Assertion >>

Post new comment