means, we can't see them, but we divided RAM to them.
you have a class Student. And you want to create an instance of it, right? You write:
Student Ali=new Student(); // nice!
variable which called Ali, "lives" in Heap. Because, this variable has no stable size. Its size depends on its properties.
But!
int ageOfAli=20; // this is an integer, int type!
ageOfAli "lives" in stack! because, it has stable size. 4 byte!
Of course, this topic isn't easy like this. (with 3 sentences) you need to search about them.
What is meaning of words stable and lives?
Обсуждают сегодня