Geek Culture
Published in

Geek Culture

Effective Java! Return Optionals Judiciously

Photo by Nubelson Fernandes on Unsplash

Prior to Java 8 if a method didn’t want to return a value some of the time and return a value at other times there were a few options. The method could return a null, the method could throw an exception, or you could come up with some state holding object that could be returned (although I've never seen this). The first two options aren't great. Returning nulls is just asking for Null pointer exceptions…

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

API mocking with OpenAPI

Day 2

Looking to split a larger file (LoC) into smaller ones?

Advanced iOS App Architecture Explained on MVVM with Code Examples

No Degree, No Problem

Ethical Hacking (Part 7): Metasploit Penetration Testing Framework

Habits to Become Successful at Software Engineering

Angular and Firebase — The Perfect Pair: Part 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kyle Carter

Kyle Carter

I'm a software architect that has a passion for software design and sharing with those around me

More from Medium

Pitfall When Using Java Okta SDK JWT Verifier

Spring — Never Rollback Readonly Transactions

Auto-configuration with Spring Boot

SOLID Principles in Java