Java 中整數的最大可能值是多少?


MAX_VALUE 用於找出 Java 中整數的最大可能值。我們來看看一個例子 -

示例

 線上演示

public class Demo{
   public static void main(String[] args){
      System.out.println("The type is");
      System.out.println(Integer.TYPE);
      System.out.println("The size is");
      System.out.println(Integer.SIZE);
      System.out.println("The max value of integer is");
      System.out.println(Integer.MAX_VALUE);
   }
}

輸出

The type is
int
The size is
32
The max value of integer is
2147483647

一個名為 Demo 的類使用 Integer 類,並給出 Integer 類的各種特徵,例如型別、大小和最大值。整數可以容納的最大值可以透過使用 MAX_VALUE 值呼叫 Integer 類來計算。它顯示在控制檯上。

更新日期: 2020 年 8 月 17 日

2K+ 瀏覽量

開啟你的事業

完成課程即可獲得認證

開始吧
廣告
© . All rights reserved.