Null Pointer Exceptions In Java - What EXACTLY They Are and How to Fix Them

preview_player
Показать описание
Full tutorial for Null Pointer Exceptions in Java.

Null Pointer Exceptions! Every Java programmer has run into this dreaded Exception.

But what exactly causes a NullPointerException in Java? We'll talk about What a null pointer exception is, how to fix it, and how to avoid them in our Java code.

NullPointerExceptions can be scary and confusing, but they're simple to fix as long as you understand why they happen.

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

📕 One of my favorite programming books, Clean Code by Robert Martin

🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial

🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)

📹Phone I use for recording:

🎙️Microphone I use (classy, I know):

Donate with PayPal (Thank you so much!)

☕Complete Java course:

Рекомендации по теме
Комментарии
Автор

I never clicked faster on a video before

oligawen
Автор

Great video explaining that concept. In general I really like your videos. But I was missing the mentioning of Optional<> in that context. Maybe you could make a follow up video to complete the null topic.

redcrafterlppa
Автор

Hi John, good explanation as always. I'd like to suggest you cover BigDecimals in Java in your upcoming video and do a comparison with other types

raz
Автор

Hi John, I've recently subbed to your channel. The thumbnails and titles to your videos are just spot on and your videos are short but full of information that are very helpful. I hope you help more learners like me.

cedricmendoza
Автор

Another great video, John. I've gotten to the point in my practice where I'm considering initializing stuff to null. This came just in time.

socaljusticewarrior
Автор

Man I work at company with a pre 14 Java version and you have no idea how many times I had a npe on a line with like 5 different objects and I would have no idea where to start. I actually didn’t know about the new exception text, very nice!

chvis
Автор

Well I didn't think I'd learn anything but I did! Written 10 Spring Boot microservices over the past 3 years or so with Java 8. Whenever I got those null pointers (ex: ) I would just end up System.Out.Println to console for debugging to see what was null. Java 14 or higher migration here I come! I can't believe something as useful as this wasn't put in earlier versions of java. Thank you for the great content as always!

Also @ 11:42 instead of returning new ArrayList<>() you can just return Collections.emptyList().

briansutton
Автор

As always, exactly just what you need to understand the topic. Thanks John for these great videos.

aidoka
Автор

I have registered yesterday to John's course. I highly recommend his course. he is unbelievably good.

nesuleo
Автор

John is such a natural teacher. Great communicator, excellent teaching vocal, well-organized materials and examples. Easy to follow. I bought his Java programming tutorial. Great for very beginners. I wish he develops more advanced topics.

feiwong
Автор

I am waiting for this topic for a long time. Great explanation. Thanks John so much

khiemdo
Автор

Thank you so much John, you are the only one able to teach me Java and put a smile on my face at the same time, I hope you de best.

josenavio
Автор

A nice way to do chains of null checks is with optionals:

For example: If i want to return some value a.getB().getC().getD(), i can just do:
return

christophdietrich
Автор

Hi John, thanks for the brilliant video.

gahnendesgnu
Автор

The best java channel on Youtube. Good job, John!!!

teslagang
Автор

I always learn something new with you! Thanks a lot!!

gabucarneiro
Автор

You are THE BEST. precise and concise to perfection

richiemercury
Автор

Thank you for sharing this awesome video Jhon. I wonder if In the future you could share some tips and tricks with Maven, Spring, or Webservices. The way in which you turn complex things into simple concepts is beautiful.

felipel.r.
Автор

Very good video, thank you for the lessons!

alfredomenezes
Автор

as always you nailed it, thank you a lot for your great way to teach us what we really stuck with for a long time :)

ahmedbishree