In our previous blog we discussed first three of the 5 Most Common Mistakes Java Developers Can Avoid, which included the following:
- Forgetting to Check Existing Libraries
- Omitting the ‘break’ keyword in Switch-Case
- Not Freeing Resources
These three mistakes are explored in detail in the previous post. Let’s discuss two more mistakes committed by Java Developers here:
4. Causing Memory Leaks
While Java automatically allocates and frees up memory, some problems can still arise if a program uses references to objects that are not needed anymore. This is because even the garbage collector is unable to remove objects that have references to them. Even cross referencing objects are not removed by the GC since they cause circular dependencies. Therefore, one must take care not to cause such memory leaks.
5. Ignoring Exception Handling
Exceptions are thrown for a reason. Make it a practice to handle these exceptions after understanding the reason behind such behavior. Addressing the issue head on is the best practice that can be followed by beginners or experienced developers alike. You can either show an error dialog to the user, or add a message to the log.
Java SE 7 Programming Certification Training from Koenig Solutions will assist Java developers on How to Get Java Certification and demonstrate ways to avoid many more common mistakes, thereby enabling developers to become highly skilled and proficient in creating rich and user-friendly Java applications.