Optionals In Java - Simple Tutorial

Optionals In Java - Simple Tutorial

Coding with John

1 год назад

193,354 Просмотров

Full tutorial on Optionals in Java!
Thanks to FlexiSpot for sponsoring! 🖥️ Get your coupon code for an extra $30 OFF through my link: https://bit.ly/3QPNGko

FlexiSpot Pro Plus Standing Desk E7
https://bit.ly/3xTvGNF (US site)
https://bit.ly/3OEL9aT (CAN site)

Join FlexiSpot Member Day during 29-30th June 2022! Up to $100 OFF! https://bit.ly/3u0akNa
#MyFlexiDesk #flexiblewfh

Complete Java course: https://codingwithjohn.thinkific.com/courses/java-for-beginners

Optionals were added in Java 8, but can be a confusing thing to learn. This tutorial will walk through all of the aspects of Optionals in Java detail, then walk through step by step when and how to use optionals in your own code!

If you're confused by Optionals in Java, either just what they are and why they exist in general, or how to code to use them in Java, you're in the right place!

Learn or improve your Java by watching it being coded live!

Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.

Let me know what else you'd like to see!

Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.

📕 THE best book to learn Java, Effective Java by Joshua Bloch
https://amzn.to/36AfdUu

📕 One of my favorite programming books, Clean Code by Robert Martin
https://amzn.to/3GTPVhf

🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
http://www.audibletrial.com/johncleancode



🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
https://bit.ly/3QPNGko

📹Phone I use for recording:
https://amzn.to/3HepYJu

🎙️Microphone I use (classy, I know):
https://amzn.to/3AYGdbz

Donate with PayPal (Thank you so much!)
https://www.paypal.com/donate/?hosted_button_id=3VWCJJRHP4WL2


☕Complete Java course:
https://codingwithjohn.thinkific.com/courses/java-for-beginners

https://codingwithjohn.com

Тэги:

#java #codingwithjohn #coding_with_john #java_beginner_lesson #java_8 #java_8_optional #java_optionals #optional_in_java_8 #optional_usage_in_java #java_8_features #java_tutorial #what_is_java_optional_class #what_is_optional_class #java_optional #java_8_interview_questions #java_optional_ifpresent_return_value #java_optional_tutorial #java_8_tutorial #java_8_lambda_expressions #java_8_new_features #java_8_interview_questions_and_answers #learn_java #java_full_course
Ссылки и html тэги не поддерживаются


Комментарии:

Rishi Raj
Rishi Raj - 06.10.2023 10:17

thanks

Ответить
Clarence Donovan
Clarence Donovan - 26.09.2023 15:53

"orElse, It almost sounds like a threat." I laughed at this more than I should have. 😂

Ответить
Saif
Saif - 25.09.2023 00:03

Wow John didn't know you were so tall 😮

Ответить
Milton Ezeh
Milton Ezeh - 18.09.2023 11:22

You are the BEST on these streets.

Ответить
Rodje
Rodje - 12.09.2023 00:12

Schrodinger's object

Ответить
Leandro Oliveira
Leandro Oliveira - 07.09.2023 02:34

The best is the final .. advice where to use, generally in return of funciona, not every where creating a mess.

Ответить
ROAD TRIPS AFRICA
ROAD TRIPS AFRICA - 06.09.2023 06:30

The cat 😂....nice video.... What video editor do you use Sir?

Ответить
Alex L.
Alex L. - 14.08.2023 15:42

you are explaining sooo weeelllll O_o thanks a lot!

Ответить
Joao Lima
Joao Lima - 11.08.2023 02:42

Precious content, thank you! Greetings from Brazil 😊

Ответить
The Juls
The Juls - 10.08.2023 02:56

Schrödinger’s Optional

Ответить
Reza Hajivand
Reza Hajivand - 07.08.2023 15:42

Hello mr jhon .
Thanks for your teaching video 🎉🎉🎉

Ответить
narendra singh shekhawat
narendra singh shekhawat - 04.08.2023 08:40

hahaha ,.. u have a cat in real ,.. so cute , pretty .. Now i got to know Why cat object is there in many video. Give me this optional<cat> to me .. orElse ..

Ответить
mohammad sadegh sheikh zahedi
mohammad sadegh sheikh zahedi - 03.08.2023 15:16

Great job 🙏

Ответить
Mayank Gupta
Mayank Gupta - 24.07.2023 22:09

Can't resist writing a review, I am preparing for a job as a developer and chose Java as my technology, I have been learning since 4 months now, I was completely devastated and lost few days back as I am not getting any calls for the interviews, luckily discovered your channel and since then I have been going through all the concepts again from your videos, it's just making me so much more confident and stronger, your energy is just pure GOLD!

All the topics have been explained crisply.

Hope I'll soon land a good offer!

Lots of love from India!
❤❤❤❤

Ответить
Personal Account
Personal Account - 22.07.2023 05:50

Thanks! Direct to the point, it worth all 16 minutes. If I could give 100 likes I will ask why I can't give 1,000

Ответить
Ali Hosseinkhani
Ali Hosseinkhani - 19.07.2023 14:45

nice, thank you

Ответить
J. FranciscoX
J. FranciscoX - 17.07.2023 23:26

Love that desk setup, could you do a video about your desk setup? And maybe other stuff as well, such as your favorite IDE, text editors etc.

Ответить
GOVIND GUPTA
GOVIND GUPTA - 15.07.2023 08:08

make a video on StringUtils

Ответить
User 001
User 001 - 14.07.2023 11:53

John is the best

Ответить
Yati Acharya
Yati Acharya - 08.07.2023 11:12

You know how I am certain this is the best Java channel? I have no interviews to crack, I have no exams to clear and I'm still here learning because it just is explained in such an interesting, problem-solution kinda way.
Brilliant work, John!

Ответить
Mohammed Albj
Mohammed Albj - 08.07.2023 06:39

This is pure gold, thank you so much!

Ответить
James Hrivnak
James Hrivnak - 05.07.2023 18:18

Very cool, thanks for sharing this information -- just to be nitpicky -- would negative 1 not be a better age to fallback on instead of 0? Kittens can be of age 0 for example -- my comment is less about the technicalities of feline lifespans and more about if in Java- is -1 is an more idiomatic way to express a fallback number for a value that could be 0 OR > 0? For example this is the case in JS where methods like indexOf will return -1 to express that the searched value doesn't exist at any index. OR is it that in java specifically that -1 has a specific integer type that would have complicated your video and been outside of the scope of the subject you were discussing?

Ответить
Isha Tawade
Isha Tawade - 04.07.2023 16:59

Loved your explanation with Cat :) as I am a cat person

Ответить
Raze955
Raze955 - 04.07.2023 07:13

Schrodinger's cat

Ответить
Andrew
Andrew - 29.06.2023 03:34

You didn't call it schrodingersCat, my disappointment is immeasurable and my day is ruined.


But otherwise great tutorial xD

Ответить
Asher Khan
Asher Khan - 27.06.2023 13:29

Great explanation John

Ответить
Md Lutfar Rahman
Md Lutfar Rahman - 27.06.2023 10:24

Absolutely brilliant teaching style.

Ответить
Anton Pegov
Anton Pegov - 25.06.2023 13:45

Why not tell the truth? Why no tell that we stall Undefined from the JS?

Ответить
Andrew Anew
Andrew Anew - 25.06.2023 07:34

algorithm

Ответить
Скорець Роман
Скорець Роман - 23.06.2023 10:50

+++

Ответить
Rockyzach88
Rockyzach88 - 21.06.2023 18:20

6' 5''? Didn't know I was learning from a giant.

Ответить
Asif Shaikh
Asif Shaikh - 21.06.2023 00:40

why don’t we have something like this obj.isPresent().get().orElse(“do something”). ??

Ответить
Flávio André
Flávio André - 16.06.2023 01:50

Awesome

Ответить
the thing
the thing - 14.06.2023 00:57

thank tho i will never use it in my carer

Ответить
Gabriel Fono
Gabriel Fono - 09.06.2023 05:19

this is so amazing
as backend engineer, I 100% agree
thanks a lot

Ответить
Rupesh Saxena
Rupesh Saxena - 07.06.2023 19:18

guard keyword should also be introduced in Java to handle optionals in a systematic way…

Ответить
Chris's Garage
Chris's Garage - 06.06.2023 21:22

I would risk a Code Review bollocking to have called the Optional Variable schrodingersCat.

Ответить
Rikkarth
Rikkarth - 01.06.2023 11:06

Thank you, this video has helped me immensely.

Ответить
Sphesihle Manuel
Sphesihle Manuel - 31.05.2023 17:56

Alright I've had enough of you cooking I'm subscribing 🥵

Ответить
Stephanie Panah
Stephanie Panah - 29.05.2023 06:51

Fred is a really huge cat

Ответить
Adam Wu
Adam Wu - 29.05.2023 02:07

This is why I like C#, you just simply cat?.GetAge() ?? 0

Ответить
Oscar Gamarra
Oscar Gamarra - 27.05.2023 21:48

Idk if I learned something or if I was threatened subliminally?

Either way, it stuck. Thanks!

Ответить
Aline Sinclaire
Aline Sinclaire - 27.05.2023 00:31

I m surprised there is no comment on the cat and the box ? that was the best part

Ответить
Aline Sinclaire
Aline Sinclaire - 27.05.2023 00:29

epic explanation with the cat in the box it was so funny!

Ответить
Łukasz Kiepas
Łukasz Kiepas - 25.05.2023 00:37

big WOW

Ответить
Łukasz Kiepas
Łukasz Kiepas - 25.05.2023 00:32

thank you :)

Ответить