What is an Optional? #javalanguage #javacodinginterview #javacoding #javatips

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 203: What is an Optional?
Рекомендации по теме
Комментарии
Автор

I used Optional many times recently, but this video gives me more insight to it. Thanks.

yemzibossa
Автор

I find that Optional can somewhat reduce chained nullness checking (object with nested objects), a cost for performance, but a gain for readability, and maybe cognitive complexity.

VuLinhAssassin
Автор

That may have been the original intent, but after taking notes (probably from Scala & others) Java 9 realised it should ALSO be thought of as a container with max size 1. (It makes its methods like stream and filter make more sense when looked at this way.) It is a shame OptionalInt etc were not consistently rationalized in the same way.

lukeusherwood
Автор

This is like someone explaining what a knife was originally intended for.

captainmcface
Автор

Wait… I’ve been using Optional as an alternative to returning null. It’s been working well for me, but is that wrong?!

sleepy-girl
Автор

I dont know why some complex problems in java can be solved easy in kotlin or scala. Why does java not just copy that behavior?

alskaa