You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
Returning an empty Optional is no more expensive than return null.
Using Optional can avoid numerous null checks at call sites (which can be forgotten as new code is written).
Modern JVMs are very efficient at managing short-lived objects, so using an Optional to wrap a result is not excessively costly. Of course, actual performance data to prove using null is better here can change the story, but until we have such concrete performance data, we are better off using better programming practices and not using null for control flow.
The text was updated successfully, but these errors were encountered:
Returning an empty Optional is no more expensive than return null.
Using Optional can avoid numerous null checks at call sites (which can be forgotten as new code is written).
Modern JVMs are very efficient at managing short-lived objects, so using an Optional to wrap a result is not excessively costly. Of course, actual performance data to prove using null is better here can change the story, but until we have such concrete performance data, we are better off using better programming practices and not using null for control flow.
The text was updated successfully, but these errors were encountered: