Overview
The assert statement lets you document and test assumptions about your program. You do so by writing boolean expressions that should always be true. If they don't, and you have enabled the execution of your assumptions, the assertion will throw an AssertionError. JarFiller uses assertions a lot, as it is a quick and concise way of showing the reader the expected result of an operation.
When to use assert?
Use assert when..
- you want to show assumptions to the source code's reader
- you want to check at runtime that an assumption is true
Do not use assert when..
- checking arguments of public methods. Any assumption about arguments is part of their contract, and if it is not fulfilled, you should throw an appropriate exception (e.g. IllegalArgumentException)
- you expect that the assertion may actually be false sometimes. Then you use a regular if statement and throw an exception on error.
Java supports the assert statement since version 1.4 (in other words, practically forever).

