Java Optional, NullPointerException Killer? Part 1

Pubblicato il: 15 febbraio 2019
sul canale di: MVP Java
5,657
138

The Java Optional class was introduced in Java 8 in order to help stop the propagation of null being returned to client facing methods.

The problem is that everyone started using it everywhere they say null. This caused confusion, un-necessary overhead and left everyone scratching their heads.

Does the Java Optional Class finally rid us of NullPointerExceptions? I’ll demonstrate how when Optional is used correctly and when combined with Java’s functional style of programming, that this is indeed possible.

In this tutorial (Part 1) we'll approach Java Optional with a Problem/Solution approach and then cover...

how to create and retrieve an Optional value
Where is the best place to use Java Optional (recommendation)
Introduction to pitfalls and how to use Java Optional with an
Imperative style of programming via Optional methods isPresent
and get
Introduction to Functional Style via Optional methods map,
ifPresent and ifPresentOrElse

You can see Part 2 of "Java Optional, NullPointerException Killer?" here ...
   • Java Optional, NullPointerException K...  

The Source code is available onGitHub at https://github.com/mvpjava/java-optio...

I've also written a blog post ..
"Optional, NullPointerException Killer?"
which covers other aspects on the Java Optional Class.
Check it out here ...
http://mvpjava.com/java-optional/

======================================================
Follow me ...
Website: http://www.mvpjava.com
Facebook:   / mvpjava  
Twitter :   / mvpjava  
GitHub : https://github.com/mvpjava

Subscribe to MVP Java ...
https://www.youtube.com/c/MVPJava?sub...


In questa pagina del sito puoi guardare il video online Java Optional, NullPointerException Killer? Part 1 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato MVP Java 15 febbraio 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 5,657 volte e gli è piaciuto 138 spettatori. Buona visione!