When the computer encounters an assertion during the execution of the program, it evaluates the condition. If the condition is false, the program is terminated. Otherwise, the program continues normally. Assertions of this form are not available in Java, but something similar can be done with exceptions. And it would be better style to define a new exception class instead of using the standard class IllegalArgumentException .
Assertions are most useful during testing and debugging.
Once you release your program, you don't really want it to crash. Run the program. . That is, if the program is compiled in one way, then the assertions are included in the compiled code. If the program is compiled in another way, the assertions are not included. During debugging, the first type of compilation is used.