简体   繁体   中英

space complexity of wrapper classes

So I'm working on a presentation where I'm trying to show how much more effective a certain program would be if we were to use primitive types instead of wrapper classes, and I'm trying to find the space complexity of different wrappers and how many bytes are being used for which tasks. Can someone help me figure out how many bytes are being used for what in an Integer or a Double?

Thanks!

So the answer to this is that an Integer is 16 bytes. Essentially every object in Java requires 8 bytes of header room for the pointer (reference, etc.), 4 bytes go to the actual int data, and 4 bytes go to "padding"

source: Integer vs int: with regard to memory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM