Skip to content
Advertisement

What are good light-weight design patterns for avoid nulls in Java?

Obviously one of the greatest banes of Java programming is nulls and null-pointer exception. What design patterns are there that don’t add too much to your code but reduce the problem of sand null-pointer exceptions?

Advertisement

Answer

Null Object pattern. Look at Optional class from google-guava library.

Their wiki has an article on using and avoiding nulls.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement