java - Java int 总是 32 位吗?

标签 java

Java 的 int 是否始终是 32 位有符号整数?

最佳答案

是的,它在 The Java Language Specification 中定义.

来自 Section 4.2: Primitive Types and Values :

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, and char, whose values are 16-bit unsigned integers representing UTF-16 code units (§3.1).

另外来自 Section 4.2.1: Integral Types and Values :

The values of the integral types are integers in the following ranges:

  • For byte, from -128 to 127, inclusive
  • For short, from -32768 to 32767, inclusive
  • For int, from -2147483648 to 2147483647, inclusive
  • For long, from -9223372036854775808 to 9223372036854775807, inclusive
  • For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535

关于java - Java int 总是 32 位吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1032982/

相关文章:

java - Int 中的并置数

java - Jetty/Shiro 初始化错误 2013-06-01 03 :37:23. 574 :WARN:oejj. ObjectMBean:main:

java - 高负载项目中的Java OOM

java - 如何解决Android MultiDex应用实例空指针异常?

java - 如何在 Cassandra 中为更新集合(集合)编写 QueryBuilder 查询

java - 如何从java服务器端使用参数运行vb exe文件

java - 无法连接到 grpc 服务器并获取 'First received frame was not SETTINGS'

java - 一个与谷歌翻译相关的问题

java - Linux 中的 WINDOWS-31J 等效编码

java - 为什么在java中类可以有默认修饰符却不能被保护