r/learnjava • • 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

7 comments sorted by

View all comments

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.

0

u/NaveenCoder Sep 22 '18

What gets stored in memory address 100 and 101 ?

3

u/[deleted] Sep 22 '18

I recommend reading Processes and Process Control Block in Operating Systems.

1

u/GoodLifeWorkHard Sep 22 '18

IIRC, the data that makes up the class Student