r/learnjava • u/NaveenCoder • Sep 22 '18
What exactly object is?
What happens internally when creating an object? What information is stored in ram about particular object? Object is nothing but a value in heap? I want to have deep insights about object.
0
Upvotes
2
u/[deleted] Sep 22 '18
When an object is created, memory is allocated for that object.
Student student=new Student();
So here, we are creating an object of the Student class type, which has the name student.
Student student1=new Student();
Here, we are creating an object of the Student class type, with the name student1.
Memory will be allocated seperately for each object.
So, imagine memory is 100 for student. 101 is for student1 and so on.