Tagged articles
3 articles
Page 1 of 1
Top Architect
Top Architect
Jun 20, 2024 · Backend Development

When and How to Use Null Checks in Java: Best Practices and Alternatives

This article discusses the proper use of null‑checking in Java, distinguishes between valid and invalid null returns, proposes alternatives such as returning empty collections, using assertions or throwing exceptions, and demonstrates the Null Object pattern with concrete code examples while also noting related community resources.

JavaNull Objectdefensive programming
0 likes · 9 min read
When and How to Use Null Checks in Java: Best Practices and Alternatives
Java Backend Technology
Java Backend Technology
May 7, 2020 · Backend Development

Eliminate Excessive Null Checks: Cleaner Java Code Without try‑catch

This article explains why overusing null‑check statements and try‑catch blocks makes Java code messy, distinguishes valid and invalid null returns, and offers practical techniques such as assertions, exceptions, empty collections, and the Null Object pattern to write safer, more concise code.

Design PatternsJavaNull Object
0 likes · 6 min read
Eliminate Excessive Null Checks: Cleaner Java Code Without try‑catch