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.)

6
  • Remember that case matters, so your code won't compile because test is not the same as Test. Commented Mar 22, 2011 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? Commented Mar 22, 2011 at 15:08
  • @DaveJohnston yep, but the question is still vague without this problem. Updated. Commented Mar 22, 2011 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 Commented Mar 22, 2011 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) ... Commented Mar 22, 2011 at 15:15

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.