Showing posts with label -esa. Show all posts
Showing posts with label -esa. Show all posts

Saturday, 5 November 2011

Sun Certified Java Programmer (SCJP)-7

Assertions


An assertion is a statement containing a boolean expression that is assumed to be true when the statement is executed. The system reports an AssertionError if the expression evaluates to false. It is used for debugging purposes:

assert(a > 0); // throws an AssertionError if a <= 0



Assertions can be in two forms:


assert Expression1 ;
assert Expression1 : Expression2 ;


Expression1 should always result in a boolean value.

Expression2 can be anything that results in a value. The value is