Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Unit Testing in Java What to Test Know Your Bounds

What is a Null Pointer Exception?

This course runs through the examples of using exceptions in unit testing. But so far it has not explained clearly what exactly Exceptions are or what a Null Pointer Exception is? Can somebody explain? I'm going through the motions of doing the exercises but it hasn't clearly explained the theory behind it.

2 Answers

Bramyn Payne
Bramyn Payne
19,589 Points

This is an Exception that is thrown when you are trying to do something with a null value. This could be trying to take the length of a null object or trying to access the field of a null object.

These links from Oracle and GeeksforGeeks do a good job to explain it in more detail.

I hope this helps!

Thanks Bramyn!