+ 1
Why the size of empty class is 1 byte but the size of empty structure is 0 bytes
3 Respuestas
+ 2
because every class extends from Object, so they have ther methods, like "toString()" , or "equals(obj)"
0
sorry not understood.Could u please elaborate
0
A class is instantiated only when you create a new object to it(even though the class is empty). There by when a new object is created to the empty class the compiler assigns address for that, address stored in memory occupies 1 byte.
Therefore the sizeof an empty class will be atleast 1 byte