optional

A collection of 1 posts

A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
Apr 3, 2022 option optional nullable type Functional Programming

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. var value = foo.getBar().getBaz().toLowerCase(); Running this snippet may result in something like the following: Exception in thread 'main' java.lang.NullPointerException at ch.frankel.blog.NpeSample.main(NpeSample.java:10) At this point, you have no clue which part is null in the call chain: foo, or the value ret

Nicolas Fränkel
A Java geek © 2008-2023
v. a56deb4269e86b045bb5b27e435f40b93bcd00c4/4045070108
Latest Posts