开发者

In java if I extend a class and don't use a super field while redefining every function does the field still uses memory?

开发者 https://www.devze.com 2022-12-24 00:50 出处:网络
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

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 ints), 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.!

0

精彩评论

暂无评论...
验证码 换一张
取 消