Integer is stored in 32 bits of memory. To find max and min values of Integer in Java we can use inbuilt fields of Integer class :
- Integer.MAX_VALUE = 2147483647
- Integer.MIN_VALUE = -2147483648
Let us look at the example code :
public class MaxValue {
public static void main(String[] args) {
System.out.println("Integer maximum value = "+Integer.MAX_VALUE);
System.out.println("Integer minimum value = "+Integer.MIN_VALUE);
}
}
Output
Integer maximum value = 2147483647
Integer minimum value = -2147483648