Java assertion feature allows the developer to put assert statements in Java source code to help unit testing and debugging. Assert keyword validates certain expressions. It replaces the if block effectively and throws an AssertionError on failure.
An example of a short version of assert keyword:
public class Assertion
{
public static void main(String[] args)
{
int num = Integer.parseInt(args[0]);
assert num <= 10; // stops if num > 10
System.out.println("Pass");
}
}