#26 Stack And Heap in Java

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing:
1) Memory management in java and typed of categories to store data in memory.
2)What is stack ?
3)What is heap ?
4) where instance variable and local variable is allocated?

#1
In java we are managing our managing our memory using two data structure stack and heap.
two categories to store data in memory:
1) Stack data structure
2) heap data structure

#2
Stack is data structure which follow LIFO(Last in First Out) principle.

#3
heap is data structure which is used to store data in form of object and object is a collection of data and method.

#4
class Student{
int instVariable; //store in object and object created in heap
public static void main(String []args){
int localVariable=0; //local variable store in stack frame of method in stack area.
Student st=new Student(); //st is reference variable store address of new Student() object
}

public int add(int num1,int num2){
return num1+num2;
}
}

-- instance variable stored in object and object are in heap therefore we can say that instance variable created in heap.
-- method declaration and definition is present in object but actual implementation present in stack frame of stack.
-- local variable created in stack during call of method.
-- stack frame of called method is present in stack area.
-- st is reference variable created inside the current stack frame and it is reference variable store address of student object created in heap area.
-- new Student() create object in heap area and pointed by his reference variable.

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

I just love you sir! I was confused for so long about heap and stack. Now its clear! U are a great teacher.

spidermanhomecoming
Автор

The best explanation anyone could ever give. As soon as I have a question in my mind, you call out that point and explain as if I asked the question in person. Just shows how perfectly the flow of the content is.

thefriendlymartian
Автор

Really Nice explained. I am following Telusko since my collage time(2018). And now I am the Senior Software Developer in reputated Product company. Big Thanks Goes to Mr Naveen. Thank you Sir!

I would like to request if you can make the playlist on AWS for Java Developers. It would be very helpful.

kapiljain
Автор

The best Java teacher I've ever encountered in my life. You are awesome sir. The understanding of the concept is sooo seamless. It's like a miracle. Thanks soo much.

ajiboladaniel
Автор

No, we don't have multiple stacks (in a single thread), those are called frames. Those frames contain multiple data structures for storing local variables, operands, return addresses, constants.

piotr
Автор

Well explained dear sir.Not only India but also all over the world students get benefited by your lecture, . This is a masterpiece that ever created by you.💜💜💜💜💜, , , , Love from Bangladesh dear sir.

mehedishuvo
Автор

Watching 2 hours before java developer interview

MohdZaid-kvyn
Автор

Thank you for the video :) I just started going into interviews again and this helped me get back to speed on the topic cause I had forgotten so much stuff throughout the year as a junior dev

MsSWAGboss
Автор

100 times better than those paid courses

ajuSiuuu
Автор

Thanks for this sir, i like when you are describing how things work using a sketch.
maybe it's just me but reading documentation that just only have text explanation is really confusing and to imagining it was really hard.

danurarya
Автор

you are really great, this content is really helpfull and thanks for the notes that you are providing in description.

rushikeshbhujbal
Автор

Hi sir, i have a question . We all know that if we wanna create an object we need to use the new keyword for that, if we don't it won't use a different part of memory ! But the question is, so why we can create a copy constructor in a class without using that new keyword and still have a different area of memory which is not gonna effect the main object ?
I would be glad if you answer me, and thanks for your great teaching skills !

minotet
Автор

sir give us a quetion bank to practice this concepts, all quetions from basic to advance, so we can practice and implement the concepts or logic. your lectures are very easy to understand!! they are very helpful thank you!!!😃😃😃

Trekshorts
Автор

When i asked my sir about instance variable he gave me such lame ans that I gave up on every being able to understanding it. Thanks!!

srushtishah
Автор

Best course imo. Can you please create exercises so we can test our knowledge and skills so far? Thank you

princeiiolaguera
Автор

Where static variables are stored?
static int in = 10;

srinivasmb-rekm
Автор

Navin sir it's totally clear thanks a lot and sir i have to join your Java backend course but Saturday is my college sir and it's 3rd year bca 7 to 12 time is not convenient sir

Coding-Just
Автор

this channel gives trustworthy content where other's just do for content sake

unemployedcse
Автор

I became a diehard fan for you sir ❤ love you and love your teachings sir

qlpexcp
Автор

wow, these tutorials are of next level for sure. thank you sir.

zr