Rahul,
It is important to note assertions are not replacements for exception handling mechanism. While exception handling helps you handle unexpected runtime conditions, assertions help you
test and debug the code that you write as an application programmer. Just like in C++, assertions help you check your assumptions at various points in the program.
The really cool thing about assertions is that it can be turned on/off when you run the program.
You do this with the -ea argument to the java interpreter. This argument by itself enables assertions in all non-system classes. You can also enable on a per-class or per-package basis:
java -ea:com.utils.sorters.BubbleSort // Enable assertions for one class
java -ea:com.utils.sorters // Enable assertions for a package
You can also use the -da argument to selectively disable assertions in classes or packages.
This will enable you to have debug statements in all the critical points without hurting the performance. Sun will eventually modifty the core Java classes to include assertions so that something more meaningful than an ugly stacktrace is displayed when things go wrong.
Hope this helps,