Java Optional Complete Guide

Опубликовано: 21 Июль 2022
на канале: Tom Gregory Tech
4,924
200

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...


Смотрите видео Java Optional Complete Guide онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Tom Gregory Tech 21 Июль 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,924 раз и оно понравилось 200 людям.