Tuesday, August 20, 2002 06:14 PM
Assert is a technique normally associated with C/C++ programming to ensure that assumptions made when coding a function/method are true. For example, if the code assumes that a parameter will never be null, the assert statement verifies this and will abort the program if the condition is false.
In C/C++, assert is a macro which is conditionally compiled. During debug/test, asserts are enabled. After testing is complete, and you're reasonably certain your code is working, a "release" build can be made that strips out asserts from the compiled code--reducing the code footprint. Java compilers supporting 1.4 features can be instructed to conditionally remove asserts.
See http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html for more info.