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

 Live Demo

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.

Updated on: 17-Aug-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements