In java if I extend a class and don't use a super field wh开发者_Go百科ile redefining every function does the field still uses memory?
The fields are still there. Primitive fields use the memory they need (e.g. 32 bits for int
s), reference fields ("object pointers") take 32 bits even if they're null. The fields have to be there even if they're not actively used, because the compiler has no way to be sure whether someone is going to need them.
Yes, the field still consumes memory.
Yes! It defaultly comes to the child class and occupies memory.!
精彩评论