What is null and a null pointer exception? (Java Tutorial)

preview_player
Показать описание
This tutorial explains null, and how to avoid and solve a null pointer exception error.

nullpointerexception

Aligned to AP Computer Science A.


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

This is the best explanation I have found on Youtube! Thank you!

lizetavasilescu
Автор

Let’s say we create an object Cat anonymous = new Cat(); what does anything have to do with the Cat in the beginning it’s the type of the object yeah but like what does that mean. So anonymous is the memory reference so is the anonymous pointing to Cat or something??

youtubeaccountx
Автор

Dear Bill, I have a question ! All we know is that, objects including instance variables are created in heap and all methods and local variables, and reference variables are created on the stack. Suppose I have,
class Animal {
int size;
public void methodA(){
// a line of code
}
}

now If I create an Animal object and I refer to it to a reference variable called dog i.e. Animal dog = new Animal(); Then I invoke the methodA() in my main() method like this dog.methodA(). Now My Question Is: How's going to object use that method cause object is in Heap and Method is in Stack!? And as far as I know from your video there's only a pointer from stack which is reference variable pointing at object which is in Heap.

shahriarmim
Автор

What is happening on the stack and heap when we call catzilla.fall() and clawdia.fall()?

guptadagger