Home >Java >javaTutorial >What is the value range of java integer

What is the value range of java integer

coldplay.xixi
coldplay.xixiOriginal
2020-08-22 10:13:185283browse

The value range of java integer is from [-2147483648 to 2147483647], including [-2147483648] and [2147483647]. The highest efficiency is when the value is [-128--127].

What is the value range of java integer

java The value range of integer is:

The value of the Integer class is consistent with the value of the int type. The value range is from -2147483648 to 2147483647 (-231 to 231-1), including -2147483648 and 2147483647.

But for the Integer class, in order to improve efficiency, Java initializes integer objects between -128--127, so the Integer class is most efficient when it takes a value of -128--127.

Test:

public class Integertest { public static void main(String[] args) {
          System.out.println("最大取值:" + Integer.MAX_VALUE);
          System.out.println("最小取值:" + Integer.MIN_VALUE);
         }
}

Output:

最大取值:2147483647 最小取值:-2147483648

Related learning recommendations: java basic tutorial

The above is the detailed content of What is the value range of java integer. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn