This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
1. Assertions are used tipically when development to test the application. Using assertions you can active or desactivate them when compiling and at runtime without changing the code. Without assertions you need to change your code and recompile to do/undo the test. Assertions are a great tool to test your application 2. Public methods can be invoked from anywhere (another programmer can use your public methods) and if you want to be sure that your method works correctly you must [B]always[B] check the arguments. If the check is done using assertions you are not sure that the check will be always done because assertions can be desactivated at runtime
hi: This answer is from Kathy and Bert Book. "Assertions let you test your assumptions during development, but the asserton code-in effect-evapurate when the program is deployed" In brief: When you test your code, you can enable assertion for JDK 1.4, and disable it-defualt- during deployment. In this situation, your code will run faster, stay smaller and cleaner. If you use "if else" your code will take a performance hit. I hope this helps
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle