Assertions in Java
1 Java Programming With Assertions by Oracle.com
- Assertions are part of language definition. Not macro based.
- E1 is a boolean expressions. E2 is an expression
that has a value.
assert E1 ;
When the system runs the assertion, it evaluates E1
and if it is false throws an AssertionError
with no detail
message.
assert E1 : E2 ;
The AssertionError
constructor uses the string
value of E2 to generate a detailed message when E1 is
false.
- Assertions in general
- Assert use cases
- Force enabling of assertions
- Assert is for private arguments only