Tuesday, April 5, 2022

Handling Null: Optional and Nullable Types

Java has long been infamous for its NullPointerException. The reason for the NPE is calling a method or accessing an attribute of an object that has not been initialized.

Java
 
var value = foo.getBar().getBaz().toLowerCase();

Running this snippet may result in something like the following:



from DZone.com Feed https://ift.tt/Ko2Oyi9

No comments:

Post a Comment