java int size fixed or variable?

后端 未结 5 2131
攒了一身酷
攒了一身酷 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 20:02

    It's fixed in size. All ints in Java are 32 bits, both from the programmer's perspective and the machine's.

    The Java VM specification, which describes the JVM bytecode format, mentions that each int is 32 bits. (Aside: boolean values can take up any number of bits, as can objects.)

提交回复
热议问题