If I need 8 variables of type boolean in a class, does Java really put them all in one byte? Or will he use a byte for each? In other words, the size of the memory depends on:
boolean a;
boolean b;
boolean c;
boolean d;
boolean e;
boolean f;
boolean g;
boolean h;
vs.
public static final int a = 0x01;
public static final int b = 0x02;
public static final int c = 0x04;
public static final int d = 0x08;
public static final int e = 0x10;
public static final int f = 0x20;
public static final int g = 0x40;
public static final int h = 0x80;
byte flags;
I ask because I will create many of these objects. Thus, getting 1 byte instead of 8 bytes of memory will be a noticeable saving.
Update: . This is exactly like related questions that list the boolean value to be stored in int (thanks for these links and wish I could find them before asking). This question is slightly different in that it represents a specific alternative to using bytes and bit flags. I do not know if this is enough so that this question is not duplicated.
2: , SizeofUtil . 8 24 / 3 /. 10 /. , 8, int ( 64- ). ?