0

If I create a class like:

public class Test{
       int id;
       String name;
}

Now, if I have to use the class, we have to just create a instance of the class as

Test testObj = new Test();

I would like to know how the actual object is created in the system. (In core level, what will be the structure of the object.)

Chris Cooper
  • 17,276
  • 9
  • 52
  • 70
Anshul
  • 635
  • 2
  • 11
  • 27
  • Remember that case matters, so your code won't compile because test is not the same as Test. – DaveJohnston Mar 22 '11 at 15:08
  • What exactly do you mean by "core level"? How the VM organizes its memory? And why do you want to know? What are you trying to achieve? – nitro2k01 Mar 22 '11 at 15:08
  • @DaveJohnston yep, but the question is still vague without this problem. Updated. – Nishant Mar 22 '11 at 15:11
  • Why is people rating down this question? The guy wants to know how a VM stores objects in memory, what's wrong with that? May be it's unimportant to most of us but that's no reason to down vote this – arg20 Mar 22 '11 at 15:14
  • why all the down votes? the guy wants to undestand classes/objects, but can't express it well (well he's learning that's why) ... – manji Mar 22 '11 at 15:15
  • You can say it as machine level processing and management. – Anshul Mar 22 '11 at 15:17

1 Answers1

4

This depends on the actual virtual machine (vendor, version). There's no detailed specification on how a VM should store the instance.

The Java virtual machine does not mandate any particular internal structure for objects.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268