How-to articles, tricks, and solutions about ASSERTIONS

What does the Java assert keyword do, and when should it be used?

The assert keyword in Java is used to define an assertion, which is a statement that you expect to be true at a specific point in your program. If the assertion is not true, then the program will throw an AssertionError.