Memory occupation of instance objects

Hi everyone,

I have a question about creation of Java instance objects.

I know that every Java object occupies some quantity of memory, depending on how many fileds have (and how big in memory are).

I want to know if a Class which contains a great number of methods (also not used) is bigger in memory than one exactly the same, but with a smaller number of methods.

For example:

publicclass Example1{

pulicint myInt = -1;

public Example1(int myInt){

this.myInt = myInt;

}

publicvoid setUp (){

.....

}

publicint getInt(){

return myInt;

}

publicvoid setInt(myInt){

this.myInt = myInt;

}

}

publicclass Example2{

pulicint myInt = -1;

public Example2(int myInt){

this.myInt = myInt;

}

publicvoid setUp (){

.....

}

}

I want to know if Example2, when created with anew, is smaller in memory than class Example1.

I don't refer to Permanent memory (meta-rapresentation of Classes and their methods)... in this case (speaking about Permanent memory) Example2 is "cheaper" than Example1.

I instead refer to memory allocated from every new instance of class Example1 and Example2.

Thank you very much all in advance.

Diego

[2398 byte] By [DiegoCarzanigaa] at [2007-11-27 7:39:35]
# 1
No, an instance does not include the methods of the class. They're loaded only once when the class is loaded. Only instance variables are in every object instance.
-Kayaman-a at 2007-7-12 19:20:15 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you very much for your answer Kayaman... I had a doubt and you clarify me.HiDiego
DiegoCarzanigaa at 2007-7-12 19:20:15 > top of Java-index,Java Essentials,Java Programming...