Posted By:
ying_lcs
Posted On:
Friday, September 1, 2006 01:04 PM
All, I have a question about Instance variable memory conumption in java? Do instance variables always consume 4 bytes? in other words, using bytes,shorts,and Boolean types do not save any memory than using an int? For example, Do these 2 classes use the same memory in heap? class A{ private byte b1; } class B{ private int int1; } How about these 2: class A{ private byte b1; private byte b2; } class B{ private int int1; } How about these 2: class A{ private byte b1; private byte b2; } class B{ private int int1;
More>>
All,
I have a question about Instance variable memory conumption in java?
Do instance variables always consume 4 bytes? in other words, using bytes,shorts,and Boolean types do not save any memory than using an int?
For example,
Do these 2 classes use the same memory in heap?
class A{
private byte b1;
}
class B{
private int int1;
}
How about these 2:
class A{
private byte b1;
private byte b2;
}
class B{
private int int1;
}
How about these 2:
class A{
private byte b1;
private byte b2;
}
class B{
private int int1;
private int int2;
}
Thank you.
<<Less