Java’s Optional class was introduced in 2014 to allow developers to represent the empty state. But what exactly does that mean? And why is it important enough to bother using Optional?
In this video you’ll learn everything you need to know about Optional: how it works, what problems it helps solve, and when not to use it.
▶️ Video chapters (Optional methods in brackets)
Why is Optional confusing? 0:00 (of, empty)
What acutally is Optional? 0:23
What we did before Optional existed 1:53
Using Optional to return an empty value 3:48
How to handle a returned Optional 4:51 (ifPresent, ifPresentOrElse, orElse, orElseThrow)
When should you NOT use Optional? 8:15 (ofNullable, isPresent, get, isEmpty)
6 more advanced Optional patterns 11:20 (orElseGet, or, filter, map, flatMap, stream)
✅ GITHUB REPOSITORY with code examples from the video to try out yourself https://github.com/tkgregory/optional...
☕ JDK 18 OPTIONAL API DOCUMENTATION referred to in this video https://docs.oracle.com/en/java/javas...
🚀 FREE GRADLE INTRODUCTORY COURSE - Get Going with Gradle - the fastest way to a working knowledge of Gradle https://tomgregory.com/gradle/courses...
🦸 GRADLE HERO COURSE TO MASTER JAVA PROJECTS - take back control of your Gradle build https://tomgregory.com/gradle/courses...
🌍 Accompanying Optional article on my website https://tomgregory.com/gradle/java-op...
Watch video Java Optional Complete Guide online without registration, duration hours minute second in high quality. This video was added by user Tom Gregory Tech 21 July 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 4,924 once and liked it 200 people.