java assert
public static void main(String[] args) { int a = 6; assert a != 6 : "a != 6"; } //Exception in thread "main" java.lang.AssertionError: a != 6 Foo result = null; assert result != null; final int result = a + b; assert (result - a == b) : "Sum of " + a + " + " + b + " returned wrong sum " + result;
Here is what the above code is Doing:
1. The first assert statement is checking if the value of a is not equal to 6.
2. The second assert statement is checking if the value of result is not null.
3. The third assert statement is checking if the sum of a and b is equal to the value of result.