Java Stack + Heap with Reference & Instance Variables

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น • 307

  • @NOCDIB
    @NOCDIB 5 ปีที่แล้ว +157

    In my 15 years of professional Java experience I must say that this is the best explanation I have ever seen of stack and heap memory. Great job!

    • @Samad_27
      @Samad_27 3 ปีที่แล้ว +1

      Is java is good to learn in 2021

    • @NOCDIB
      @NOCDIB 3 ปีที่แล้ว

      @@Samad_27 Yes. Yes it is.

    • @Samad_27
      @Samad_27 3 ปีที่แล้ว

      @NOCDIB thanks but one more question how to improve programming skills

  • @suyashgupta4019
    @suyashgupta4019 8 ปีที่แล้ว +52

    Brilliant video, couldn't have explained it any better!

  • @israayusuf3712
    @israayusuf3712 7 ปีที่แล้ว +1

    I saw your OOP videos first and I prayed God that I find some videos for the heap and stack that you explain. I can't tell you how happy I was when I found this video. THANKS A TON :")

  • @fer-torres
    @fer-torres 7 ปีที่แล้ว +2

    Not everyone learns in the same way. But, your way of explaining this makes a lot of sense to me, thank you for sharing such valuable info here!!

  • @thestarinthesky_
    @thestarinthesky_ 5 ปีที่แล้ว +10

    You have done a good job on demystifying the whole terminology things! You should be a teacher! Thanks for the subtitles too. Very helpful!

    • @kmellos
      @kmellos 4 ปีที่แล้ว +1

      He is a teacher. He has a course on udemy. Check the descriptions guys..

  • @semyonnaumov2664
    @semyonnaumov2664 4 ปีที่แล้ว +3

    The greatest explanation I've ever seen. Thank you, Imtiaz!

  • @nishant2242
    @nishant2242 6 ปีที่แล้ว +4

    the way you explain stuff is just amazing . Your udemy video on class design got me a job in a product company . thanks a ton

  • @ehsansasanian9653
    @ehsansasanian9653 5 ปีที่แล้ว +1

    This guy is really good at explaining, this is the best explanation I've ever seen of stack and heap memory.
    well done !

  • @mr.yanlucena8463
    @mr.yanlucena8463 5 ปีที่แล้ว

    WTF! This is the best video I have ever, EVER, watched! Who is this genius?! I am subscribing right now! Thank you, Imtiaz!

  • @shashipagonda
    @shashipagonda 5 ปีที่แล้ว

    I went through multiple videos to understand stack and heap where there was some lagging but after seeing this video, it makes me clear. Thank you so much for explaining in detail

  • @mostafaahmadi4998
    @mostafaahmadi4998 3 ปีที่แล้ว

    man, it was an incredible explanation with just a pen and whiteboard. Thank you

  • @davitkvaratskhelia4033
    @davitkvaratskhelia4033 3 ปีที่แล้ว +5

    I'm going to repeat it step-by-step with my students.. Cool!

  • @mrwalkan
    @mrwalkan 3 ปีที่แล้ว

    Explained Concisely. BRAVO!!

  • @amiladrck
    @amiladrck 5 ปีที่แล้ว +2

    This is the best explanation I've ever seen about the stack and heap. Thank you so much!

  • @srinivasanbalan2469
    @srinivasanbalan2469 4 ปีที่แล้ว

    You are a God's gifted teacher to all students n professionals. Hats off! Imtiaz.

  • @monowarhossainshuvo9269
    @monowarhossainshuvo9269 4 ปีที่แล้ว

    With due respect, you deserve my like, comment and obviously subscribe. Thank you so much, sir.

  • @vishnupradeep3979
    @vishnupradeep3979 5 ปีที่แล้ว +1

    I watch this every time, before I starting any new project.

  • @gossipwithahmadsalar1208
    @gossipwithahmadsalar1208 3 ปีที่แล้ว

    One of the Super Best explanations I have ever seen.

  • @sobserve
    @sobserve 4 ปีที่แล้ว +2

    That guy born with a gift of knowledge transfer, man!

  • @thestarinthesky_
    @thestarinthesky_ 5 ปีที่แล้ว +1

    I REALLY need this video at this time!That is what I have been looking for !Thank you so much. it has been super helpful!I appreciate it

  • @Adam-gp3ij
    @Adam-gp3ij 5 ปีที่แล้ว +1

    Sir, I am completely shocked ! you are AMAZING ! thank you so much

  • @Setofhornsandahalo
    @Setofhornsandahalo 7 ปีที่แล้ว +167

    Not all heroes wear capes!

    • @shivamb-s8k
      @shivamb-s8k 5 ปีที่แล้ว

      I do!

    • @skgyri
      @skgyri 5 ปีที่แล้ว +1

      Why this message here? Cant get it

    • @abhishekbarman4327
      @abhishekbarman4327 3 ปีที่แล้ว

      Not all heroes spell 'caps' correctly

  • @snowwhite2146
    @snowwhite2146 3 ปีที่แล้ว +1

    What can I say. You are very good at teaching! Thank you! I will definitely use your link to study more.

  • @MohdImran-rz9to
    @MohdImran-rz9to 4 ปีที่แล้ว

    Great explaination......thanx ...now m able to figure out what actually goes inside jre

  • @IkhsanNoorRosyidin
    @IkhsanNoorRosyidin 4 ปีที่แล้ว

    Awesome explanation bro, your hand writing is not a problem at all.

  • @RahulYadav-qg5ec
    @RahulYadav-qg5ec 3 ปีที่แล้ว +3

    Great explanation!
    BTW, String is also a class, so 'name' variable's data will also be stored on heap. (Like explained for Car)

  • @bonishagarwal6315
    @bonishagarwal6315 3 ปีที่แล้ว

    The best explanation I got for stack and heap memory.
    Thanks a lot sir.

  • @pavantejavydhik7354
    @pavantejavydhik7354 5 ปีที่แล้ว

    Thanks much Imtiaz, this video will be like a dictionary for me , you clarified lots of doubts which persists in my mind since long time
    Its a appreciable attempt to put this huge insight in such a short vid

  • @shanikayrs9116
    @shanikayrs9116 8 ปีที่แล้ว +4

    clear explanation Finally found something explain the Java concept with pleasant to listen English :)
    .

  • @aniruddhashahapurkar9244
    @aniruddhashahapurkar9244 3 ปีที่แล้ว

    Hats off!! Brilliantly explained!!

  • @salvatoreamaddio2983
    @salvatoreamaddio2983 3 ปีที่แล้ว

    You should be teaching in schools, wonderful explanation

  • @SiddhantSaraf0
    @SiddhantSaraf0 5 ปีที่แล้ว +14

    Pretty good video. Thanks!
    But there are two important points you should've covered here:
    1. Why does Java do this? I think the first question which comes to my mind is: why not store the objects on the stack too?
    2. What happens when we call a method with arguments? For example, what happens when you call the method 'doWork' using that 'age' variable: doWork(age)? How do variables work then. Or if you call doWork with a reference variable, like myCar. Things get really interesting then :p
    Other things you could've mentioned, not necessarily though:
    1. This is the right place for you to just give a quick mention of what a stacktrace is. That stack diagram with method frames is just begging for you to mention stacktraes in passing. :-)
    2. For people who might have studied DSA, might be wondering: yes, that looks like a stack but why it that called a heap?

    • @PandeyJii9632
      @PandeyJii9632 4 ปีที่แล้ว

      You have a weak mind. All the primitive variables and references put inside method including parametrs reserve place in stack inside method block

    • @PandeyJii9632
      @PandeyJii9632 4 ปีที่แล้ว

      A ref variable can nvr call a method u fool. It is called by an object to which the ref var could ref to.it is done by instantiation.and then call the method by using dot operator.

    • @garybrar5518
      @garybrar5518 3 ปีที่แล้ว +10

      @@PandeyJii9632 Him asking a question and giving possible feedback doesn't make him a fool or a weak mind. Get over yourself mate

    • @Chungus581
      @Chungus581 2 ปีที่แล้ว +1

      @@PandeyJii9632thinking curiosity is for people with weak minds is itself weak minded. Asking questions is one of the most important parts of learning

  • @30ynot
    @30ynot ปีที่แล้ว

    Great video! Best explaination I have found, thank you!

  • @narikumar
    @narikumar 3 ปีที่แล้ว

    Excellent explanation, i loved it, thanks Imtiaz

  • @ashleytulloch812
    @ashleytulloch812 4 ปีที่แล้ว

    WOW Thank you so much - I'm brushing up on my explanations of Java for an interview next week and this was incredible!

  • @MdWahidurRahmanOvi
    @MdWahidurRahmanOvi 4 ปีที่แล้ว +1

    Glad that I found this video. I have seen videos on LinkedLearning(Linda.com) Udemy, college classes no one explains this properly it's been 2 + years and now for the first time it makes sense to me that what this heap and stack are all about.

  • @maheshchoutkuri2214
    @maheshchoutkuri2214 8 ปีที่แล้ว

    Hey Thanks a lot, I am searching a lot to find what happens when we create a variable , The best explanation which I found...

  • @abhishekshah11
    @abhishekshah11 6 ปีที่แล้ว

    Clear and concise explanation. Very enjoyable!

  • @brandonlovatt
    @brandonlovatt 5 ปีที่แล้ว +1

    Imtiaz, I feel like sometimes I can hear your accent slip juuust a little. I can only imagine how hard it would was for to learn a language and really nail the accent in a clear, precise way for the native speakers you are teaching. Immense respect! Something I'm not sure I'd be capable of.

    • @MJ-cf9nl
      @MJ-cf9nl 5 ปีที่แล้ว

      And that was all what you got out of this video, right? his accent and when/how he slipped out. I hope that you paid attention and actually learned something from what he was actually explaining.

    • @uyenchang9062
      @uyenchang9062 3 ปีที่แล้ว +1

      @@MJ-cf9nl Can you chill maybe he's just a random stranger passing by and he's not even looking for learning stack and heap? You don't know for sure. Plus he's complementing Imtiaz anyway.

  • @darkata40555
    @darkata40555 4 ปีที่แล้ว

    Definitely the best explanation on youtube !!! Big thank you and subscribed ofc ;pp !!!

  • @incognito13567
    @incognito13567 4 ปีที่แล้ว

    You are the best man and you have a very nice voice. Thanks for all! Subscribed!

  • @mahmoudnoor3117
    @mahmoudnoor3117 3 ปีที่แล้ว +1

    damn man you are so cool
    your English is fantastic even for those native English speakers
    continue your great job
    and please make new playlist tutorial

  • @jeevansaimanikanta782
    @jeevansaimanikanta782 5 ปีที่แล้ว

    Sir The explanation is superb and clear. I haven't seen this much clear explanation on Garbage Collection and Stack Vs Heap. Thank You so much. Please put Videos on REST API as well.

  • @joshuaealy3243
    @joshuaealy3243 7 ปีที่แล้ว

    Best code expositor on youtube!

  • @marcus48134
    @marcus48134 4 ปีที่แล้ว

    This is crystal clear and helpful. Thanks a lot.

  • @ivanh9567
    @ivanh9567 5 ปีที่แล้ว +20

    Imtiaz: * Shows how primitive type save in the heap *
    Me: "Cool, but what about class objec..."
    Imtiaz: * Explains about class object *
    Oh man, thanks you :)

  • @rafaellalinde3154
    @rafaellalinde3154 7 ปีที่แล้ว

    Great video! been looking for a good explanation for a while and finally found it.

  • @DhundupTseringOfficial
    @DhundupTseringOfficial 4 ปีที่แล้ว

    wow this made a lot of sense, very great explanation

  • @azharmobeen
    @azharmobeen 4 ปีที่แล้ว

    Very very well explained, Good job and please keep it up.

  • @supernussknacker
    @supernussknacker 5 ปีที่แล้ว

    Very clear explanation. However you didn't mention in your first example (08:30) that String is a referenced Type. This could cause some confusion for viewers who could get the idea that the values of the String are stored on the Stack.

  • @claudiajulietachen7905
    @claudiajulietachen7905 6 ปีที่แล้ว

    Very nice explanation! Understood all! Thank you!

  • @ЮрийЛавринчук
    @ЮрийЛавринчук 7 ปีที่แล้ว

    It's the best video about stack and heap. Thnak you!

  • @dbvs007
    @dbvs007 7 ปีที่แล้ว

    nice.. very clear and you are very confident on what you say :) appreciate it and thanks again....

  • @saadiyafourie
    @saadiyafourie 6 ปีที่แล้ว

    Very helpful, easy to understand and calm. Thank you very much sir.

  • @bartballon6566
    @bartballon6566 4 ปีที่แล้ว

    you just saved my exam!

  • @madhuram6328
    @madhuram6328 3 ปีที่แล้ว

    Omg such a brilliant explanation explanation u deserve it 💯👍

  • @philipgelinas
    @philipgelinas 4 ปีที่แล้ว +1

    Indian Mark Ruffalo! Thx man! Good teacher.

  • @anantgarg1116
    @anantgarg1116 7 ปีที่แล้ว

    Loved it Imtiaz Ahmad! Thanks for your efforts :)

  • @jithinjose9190
    @jithinjose9190 4 ปีที่แล้ว

    You are awsome.....what a nice way of explanation..i love it...

  • @nymexe
    @nymexe 2 ปีที่แล้ว +1

    Finally understood 😄❤️

  • @taqikhan5418
    @taqikhan5418 5 ปีที่แล้ว

    zabardast,awsome ,enjoyed a lot. kaafi concepts hile hue the oop k mere tw

  • @adriangeorgescu7395
    @adriangeorgescu7395 6 ปีที่แล้ว

    Very easy to understand tutorial. Thanks!

  • @bruceskellator
    @bruceskellator 5 ปีที่แล้ว +1

    Thanks for the awesome explanation with examples! :)

  • @venkat757
    @venkat757 2 ปีที่แล้ว

    Nice bro.... Excellent explanation...

  • @maddcobra1
    @maddcobra1 7 ปีที่แล้ว

    Nice work! You are a good teacher.

  • @chinmaysoni4416
    @chinmaysoni4416 5 ปีที่แล้ว

    Very nice explanation!!

  • @response2u
    @response2u 7 ปีที่แล้ว +5

    Great video! Just a little point missing:
    Once bigEngine is defined in main() in the stack, it has to refer to an Engine () in the heap (that line is missing)
    Then my3Car.myEngine is set to bigEngine in the stack which is already referring to Engine in the heap.

    • @hakanahlstrom8310
      @hakanahlstrom8310 7 ปีที่แล้ว

      My question is this:
      in order to create instances of a Car, there needs to be a class named Car.java.
      so, in order to create Engines, there needs to be a class named Enigne.java?

    • @asthagarg4614
      @asthagarg4614 6 ปีที่แล้ว

      Håkan Ahlström yes of course. Since it's not a built-in class, it's our custom class.

  • @reversebitstech7395
    @reversebitstech7395 7 ปีที่แล้ว

    Simple and superb, Nice explanation. Keep it up Man!

  • @ferasmasoud428
    @ferasmasoud428 5 ปีที่แล้ว

    Great job Imtiaz, Your explanation makes sense. But when I found your channel, I was looking for how to treat the static methods and polymorphim in memory, hope you can extend your explanation to accommodate these terminologies... Best Regards. Feras

  • @selimhorri7816
    @selimhorri7816 6 ปีที่แล้ว

    lot of thanks Ahmad, I really understand it easly . I'm truly impressed .. thanks

  • @onkarvadagaonkar494
    @onkarvadagaonkar494 7 ปีที่แล้ว

    Nice explaination, easy to understand

  • @rohandrysdale1139
    @rohandrysdale1139 4 ปีที่แล้ว

    Great vid. I appreciate the clarification.

  • @ShadabRezashad
    @ShadabRezashad 4 ปีที่แล้ว

    Very nice explained 👍👌

  • @crazyprogrammer2795
    @crazyprogrammer2795 5 ปีที่แล้ว

    simply awesome keep up the great work sir

  • @christopherhayward3078
    @christopherhayward3078 4 ปีที่แล้ว

    Thank you for the video. I have a question that applies around 13:45. Let's say you define Car yourCar = myCar; (can you do this...I think so) This means myCar and yourCar point to the same memory location in the heap, as in your diagram. If you now define myCar to be a new Car(), am I correct this moves the pointer of myCar to a new slot...again as done in your video, but leaves yourCar to be pointing at your old car? Now myCar and yourCar are different cars....I am sure hope I got this.

  • @muhammadalirasuljonov799
    @muhammadalirasuljonov799 3 ปีที่แล้ว

    The best explanation , thank u

  • @rohitsharma-xt8qe
    @rohitsharma-xt8qe 5 ปีที่แล้ว

    This is really some good stuff on TH-cam 👌

  • @djordje0000
    @djordje0000 7 ปีที่แล้ว

    Great video, perfectly clear!

  • @nasrinemami3237
    @nasrinemami3237 6 ปีที่แล้ว

    thanks for fluent and easy explanation

  • @harshakada3374
    @harshakada3374 5 ปีที่แล้ว

    Great video, please do more of these videos

  • @dheerajmantena3307
    @dheerajmantena3307 8 ปีที่แล้ว +1

    awesome lecture....thanks much.....

  • @RajeshKumar28sep
    @RajeshKumar28sep 3 ปีที่แล้ว

    Great work. I thought the stack grows downward.

  • @hannahlee1500
    @hannahlee1500 4 ปีที่แล้ว

    This was amazing. Thank you.

  • @codingwithnida
    @codingwithnida 3 ปีที่แล้ว

    The best Explanation..

  • @halamercy8594
    @halamercy8594 5 ปีที่แล้ว +2

    It's like listing to music not java😂😜
    Ur explanation is far excellent 👌
    Thank you

  • @fahmidhossainSakib
    @fahmidhossainSakib 4 ปีที่แล้ว

    amazing mentor !!

  • @TheParfaitducongo
    @TheParfaitducongo 8 ปีที่แล้ว

    good job explaining brother. Nice and clear

  • @rakeshanand2008
    @rakeshanand2008 6 ปีที่แล้ว

    Hi Imtiaz, @13:59 you said myCar will contain the address of new object in heap. Wouldn't that cause error duplicate variable?

  • @a.rohimsama7222
    @a.rohimsama7222 5 ปีที่แล้ว

    Great explanation, Thank you.

  • @gelmardeguzman7159
    @gelmardeguzman7159 6 ปีที่แล้ว

    Sir thank you i finally understand what i am confused about, other explanation confused me a lot rathan than understand it but you sir i finally understand.. i subscribed immediately😁😁😁

  • @mktechnology2723
    @mktechnology2723 3 ปีที่แล้ว

    Great Job and Love you.

  • @groovysalmon6857
    @groovysalmon6857 7 ปีที่แล้ว

    Well done sir, well done!

  • @muzza49
    @muzza49 5 ปีที่แล้ว

    Really good video!

  • @korges2590
    @korges2590 7 ปีที่แล้ว

    The best explaination i have ever seen... :D

  • @saeedmirzaei1
    @saeedmirzaei1 4 ปีที่แล้ว

    Great job. Thanks so much.

  • @paoloparker8991
    @paoloparker8991 8 ปีที่แล้ว

    Thank you very very much, super well explained!

  • @aniketyadav4577
    @aniketyadav4577 4 ปีที่แล้ว

    Tysm sir I was looking for this vedio from long time

  • @COSMOPOLITANWORLD
    @COSMOPOLITANWORLD 4 ปีที่แล้ว

    Thanks a lot for this great video! very understandable!

  • @shohrabhossain2022
    @shohrabhossain2022 6 ปีที่แล้ว

    wow. i am from Bangladesh. i say that this is awesome tutorial for me.

  • @hasnmbz248
    @hasnmbz248 3 ปีที่แล้ว

    finally got it ! thank you