Skip to content

Tag: assertions

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

What are some real life examples to understand the key role of assertions? Answer Assertions (by way of the assert keyword) were added in Java 1.4. They are used to verify the correctness of an invariant in the code. They should never be triggered in production code, and are indicative of a bug or misuse of a…