Integer vs int: with regard to memory

前端 未结 4 1041
春和景丽
春和景丽 2020-11-28 08:45

I was wondering if there is a difference in the memory occupied by Integer n, and int n.

I know int n occupies 4 bytes normal

4条回答
  •  离开以前
    2020-11-28 09:11

    For int: 4 bytes used per element without wrappers, and 16 per element with a wrapper.

    A wrapped double reports as 24 bytes per element, with the actual double value as 64 bits (8 bytes).

    For more details here

提交回复
热议问题