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

  Рет қаралды 19,557

Bill Barnum

Bill Barnum

Күн бұрын

Пікірлер: 18
@BillBarnum
@BillBarnum 5 жыл бұрын
📌 Subscribe For The Latest Videos: bit.ly/36H70sy 📌 . 💻 All Java Tutorials: bit.ly/JavaTutorialsKZbin 💻 . 🤖 Learn Java In 3 Hours: bit.ly/JavaIn3Hours 🤖
@lizetavasilescu3054
@lizetavasilescu3054 5 жыл бұрын
This is the best explanation I have found on KZbin! Thank you!
@umabharathyts1998
@umabharathyts1998 5 жыл бұрын
perfect explanation ,Thank u so much!
@AlamBarmaja
@AlamBarmaja 6 жыл бұрын
Nice explanation thank you
@youtubeaccount0x073
@youtubeaccount0x073 5 жыл бұрын
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??
@BillBarnum
@BillBarnum 5 жыл бұрын
Think of it like this: Imagine that you created a name for a real life cat. In this case, the name is "anonymous." Just because you have a cat name, doesn't mean you have an actual cat. If you say "hey anonymous, go clean your fur," nothing will happen because there is no actual cat attached to that name. If you want a cat to actually do anything, you need to create a physical cat and then have the name anonymous point at the actual cat. Now that you have the anonymous name pointing at a physical cat, you can say things like "Hey anonymous, go catch a mouse."
@abrehamish
@abrehamish 4 жыл бұрын
Excellent explanation
@BillBarnum
@BillBarnum 4 жыл бұрын
Thanks for the feedback!
@guptadagger896
@guptadagger896 2 жыл бұрын
What is happening on the stack and heap when we call catzilla.fall() and clawdia.fall()?
@BillBarnum
@BillBarnum 2 жыл бұрын
fall() is a static method which means it belongs to the class. Since the method resides in the class, an instance of the class (object) doesn't need to exist to access it.
@youtubeaccount0x073
@youtubeaccount0x073 5 жыл бұрын
I hope I get a 5 of AP CS A 🙏
@shahriarmim4696
@shahriarmim4696 6 жыл бұрын
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.
@BillBarnum
@BillBarnum 6 жыл бұрын
The reference variable dog would be on the stack, but dog would be pointing to an object of type Animal on the heap. When you called dog.methodA(), it would call the method from the object on the heap that the dog variable was pointing to. Bear in mind this analogy is not a perfect representation of what Java does in the background.
@hemnahmed1160
@hemnahmed1160 6 жыл бұрын
Great!
@illmatic33
@illmatic33 4 жыл бұрын
Watch at 1.25 speed, thank me later
@BillBarnum
@BillBarnum 4 жыл бұрын
Good advice.
@illmatic33
@illmatic33 4 жыл бұрын
link for memory handling kzbin.info/www/bejne/goXRoWpvgMprfKs
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 342 М.
Checked vs. Unchecked Exceptions in Java Tutorial - What's The Difference?
10:14
Every team from the Bracket Buster! Who ya got? 😏
0:53
FailArmy Shorts
Рет қаралды 13 МЛН
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН
🎈🎈🎈😲 #tiktok #shorts
0:28
Byungari 병아리언니
Рет қаралды 4,5 МЛН
Objects and References with Polymorphism (Java Tutorial)
5:04
Bill Barnum
Рет қаралды 11 М.
Getters & Setters (Java Tutorial)
8:47
Bill Barnum
Рет қаралды 4,3 М.
you will never ask about pointers again after watching this video
8:03
Checking Equality in Java ( == vs equals method )
12:32
Bill Barnum
Рет қаралды 8 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 578 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 680 М.
C++ Super Optimization: 1000X Faster
15:33
Dave's Garage
Рет қаралды 333 М.
Primitive and Reference (Object) Types in Memory (Java Tutorial)
5:12
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1,1 МЛН
Every team from the Bracket Buster! Who ya got? 😏
0:53
FailArmy Shorts
Рет қаралды 13 МЛН