java int size fixed or variable?

后端 未结 5 2126
攒了一身酷
攒了一身酷 2021-02-12 19:38

Is integer size in java of fixed length or variable size?

ex: 1 or 10000 does both the number takes same space during allocation?

5条回答
  •  深忆病人
    2021-02-12 19:47

    Java integers are 32 bits (4 octets) as per the JLS.

    The integral types are byte, short, int, and long, whose values are 8-bit, 16-bit, 32-bit and 64-bit signed two's-complement integers, respectively.

    Source: JLS §4.2 Primitive Types and Values

提交回复
热议问题