Java Classes, Objects, Stack and Heap Memory Explained - Part 1 of 2

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ค. 2024
  • Hi There,
    This video is explanation of basic but very important java concepts Class, Object and how the Objects are stored under the hood on Heap Memory

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

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

    man, am I glad I found this channel. All other channels just show you the code and sometimes, what it does. But NOBODY tells you what happens in the background.
    I'm taking my OCA in a couple of months and I believe I've just found the perfect resource to help me ace the test. Good work.

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

    I was confused about memory management in java...now all clear. Thank you for an amazing presentation.

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

    That was really awesome presentation, please keep going sir.

  • @wahyukoco4562
    @wahyukoco4562 ปีที่แล้ว

    This is what i actually need. Thanks!

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

    Thank God i found this gem 🙏❤️ thanks sir.

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

    very nice explanation , i understand clearly .

  • @neofytosioannou2043
    @neofytosioannou2043 ปีที่แล้ว

    Well explained, very good job!

  • @trevorphilipsindustries1046
    @trevorphilipsindustries1046 ปีที่แล้ว

    Awesome job, man, thank you!

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

    Awesome! its help me alot! Thank you!

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

    I watched, I benefited, I absolutely adored, I subscribed... Thanks a bunch...

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

      Appreciate it. Thanks for the feedback.

  • @dileepsimham9302
    @dileepsimham9302 ปีที่แล้ว

    very well explained

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

    Great!! thanks a lot

  • @joaovilasboas9008
    @joaovilasboas9008 หลายเดือนก่อน

    Sooo good!
    thankss

  • @shama925
    @shama925 2 หลายเดือนก่อน

    Yours is one of the best videos I watch to get a clear understanding of Java. But Java has become the basic or back bone, so can you create more videos detailing Spring Cloud, micro services etc

    • @harrygill6169
      @harrygill6169  2 หลายเดือนก่อน

      Hi Shama, thanks a lot for your feedback. Yes I do have plans to create more videos on whats used on actual job, the reasonI started with this is to get the basics strong and most of the interviews will have mainly basic questions cleared first. But I will get there eventually. Thanks

  • @TheRr1990
    @TheRr1990 3 หลายเดือนก่อน

    The explanation was too good, can u pls create a playlist. That'll be very much appreciated.

    • @harrygill6169
      @harrygill6169  หลายเดือนก่อน

      Thanks for the great feedback. I have created multiple playlists on different topics. Please feel free to go to my account and go over your topic of interests.

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

    Nice way of explanation

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

      Thanks for feedback. Glad it was helpful.

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

    awesome

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

      Thanks Praful, for the feedback appreciate it!

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

    Thanks you sir it was fab✨✨✨✨

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

      Thanks a lot. Appreciate your feedback.

  • @usai-gm2zy
    @usai-gm2zy หลายเดือนก่อน

    Hi sir, Your teaching style is very effective, and the visuals you provided have greatly aided our understanding of memory management. Could you please explain the following concepts with visuals?
    After writing the Java code with .java extension
    we will compile it using a Java compiler (like javac)
    After compilation, the bytecode is loaded into the method area of the JVM . The method area stores class-level data like method bytecode, static variables, and type information. Here I would like to know how these data will be saved in Method area with your style of visuals ?
    Static variables are allocated memory space in the method area. They exist for the entire duration of the program and are initialized with default values (if not explicitly initialized) when the class is loaded.
    Static methods are also loaded into the method area. When a static method is invoked, its local variables are allocated memory on the stack. These variables exist only for the duration of the method invocation.
    When the main method is called (which is static), it too is loaded into the method area. As the main method is executed, any local variables declared within it are allocated memory on the stack.
    Please kindly explain the above concerns with visuals, how you explained for object creation
    Thank you sir

    • @harrygill6169
      @harrygill6169  หลายเดือนก่อน

      Thank you for the suggestion I will try to create a video with this level of detail. Ones I do I will post the link here. Hopefully soon. Thanks.

    • @harrygill6169
      @harrygill6169  4 วันที่ผ่านมา

      Hi There, I have prepared a video on your demand please have a look and see if its clearer now. Happy to answer any questions 😊
      Java Stack, Heap and More
      th-cam.com/video/y0J0hS158sg/w-d-xo.html

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

    Sir please make vedio on how array stores in heap

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

      Hi Jahnvi, sure I will create one soon and let you know. Give me a couple days I will ping back ones ready.

  • @mahendramungamuru9500
    @mahendramungamuru9500 ปีที่แล้ว

    It's not better it is the best ☺️ .... I have one doubt here when we create an object using a new keyword the next is person() right what is this actually I know this is a constructor but what it does exactly
    Any information will be helpful to all please share your knowledge ☺️

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

      Hi Mahendra, so think of constructor as a special method where you can pass in parameters to set the properties of the object. When new Person() is executed the constructor of its parent, Object (note the capital O) is called and that way JVM knows to allocate space in the heap. How exactly it happens we as developers don’t really need to know but if you are curious can look at other resources, sorry I don’t know more low level than that.

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

    Please make more video on this topic

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

      Hi Naman, I have already covered more topics on the basics have a look at my ocp certification playlist.

  • @thimothipalipaka852
    @thimothipalipaka852 ปีที่แล้ว

    Student a = new Student();
    When we create a object like this , the jvm loads all the object data(like properties, methods)in the form of byte code in a heap memory area.
    In stack memory, frame is Creted for main method from that the code executes line by line what is containing in that
    The jvm converting the byte code of instructions containing in main method into binary language .
    But some of them says the entire object is loaded in physical memory (means all object data in binary form )please clarify sir which one is correct......

    • @harrygill6169
      @harrygill6169  ปีที่แล้ว

      Sorry for the delayed response, if I understand your question correctly you are asking if the data is loaded in memory in byte code or binary format? Did I get that correctly?
      In general think of Byte code as java program that the computer can understand. The code you write in the .java file is converted into byte code. The instructions mentioned byte code are understood by JVM. Byte code is stored in .class files.
      When it comes to loading the java into memory its all done in binary format byte code does not come in play.
      Please let me know if I have answered your question or you have more followup questions. Thanks.

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

    @10:05, Um, why does the STACK keeps occupying its memory, when it's only a local variable pointing to the heap?
    Added remarks: main() and p.sayYourName() are the only two added in the stack right, the rest are local and pointers. then at the end of the scope of main() the java GC will do its thing.

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

      The local variables will live until the the surrounding method (main in our case) is being executed. As soon as the jvm sees the closing curly brackets of main method the local variable wont be alive anymore and which is when stack would be cleared. In short as long as a local variable is in scope it will stay on stack. Hope it makes sense if not happy to explain again.

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

      I do have a questions, what would happened to the heap or to the instance object if its contructor call a function/behavior? And so Where do this function live (stack or heap)?

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

      Good question. The function/behaviour live on a special type of memory called method area. A method/behaviour is just set of instructions and not a storage of value like a variable. I think this special area on the heap but don’t really count as heap. As a developer you don’t have to care where it live exactly JVM will take care of it. Hope that clears the concept.

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

    Sir please make vedio on , inheritance

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

      Noted. I will create one as soon as I can. Thank you!

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

      @@harrygill6169 thank you sir

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

    Please Zoom the application for more clarity

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

      Hi Deepti, thanks for your inputs. This was one of the very first tutorial I made so have got better at it now.

  • @MissPiggyM976
    @MissPiggyM976 5 หลายเดือนก่อน +2

    Too small on mobile phone...

    • @harrygill6169
      @harrygill6169  5 หลายเดือนก่อน

      Appreciate your feedback. I will take this in account in future. Thanks much.