Computer >> Computer tutorials >  >> Programming >> Java

What is the maximum possible value of an integer in Java ?


The MAX_VALUE is used to find the maximum possible value for an integer in Java. Let us see an example −

Example

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);
   }
}

Output

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

A class named Demo uses the Integer class and gives the various characteristics of the Integer class such as type, size and max_value. The maximum value that an integer can hold can be computed by calling the integer class with the MAX_VALUE value. It is displayed on the console.