Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Assertion

Andr's picture

Second Form of Assertion

0
Your rating: None
Second form of Assertion

The second for of assertion takes another expression as an argument.

The syntax is,

assert expression1 : expression2;

where expression1 is the condition and must evaluate to true at runtime.

This statement is equivalent to
Andr's picture

Enable Java Assertion

0
Your rating: None
Enabling Or Disabling Assertion

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.
Andr's picture

Java Assertion, Java Assertion Classes

2
Your rating: None Average: 2 (1 vote)
Java Assertion Assertion facility is added in J2SE 1.4. In order to support this facility J2SE 1.4 added the keyword assert to the language, and AssertionError class. An assertion checks a boolean-typed expression that must be true during program runtime execution. The assertion facility can be enabled or disable at runtime.
Syndicate content