EN
Java - min and max int value (int range)
8
points
In this short article, we would like to show what is min and max int
value in Java.
Quick solution:
Integer in Java is in range from
-2147483648
to2147483647
.
int minValue = Integer.MIN_VALUE; // -2147483648
int maxValue = Integer.MAX_VALUE; // 2147483647
Practical example
Hint:
Integer
class is located injava.lang
package and is imported automatically.
public class Program {
public static void main(String[] args) {
int minValue = Integer.MIN_VALUE; // -2147483648
int maxValue = Integer.MAX_VALUE; // 2147483647
System.out.println("minValue: " + minValue); // minValue: -2147483648
System.out.println("maxValue: " + maxValue); // maxValue: 2147483647
}
}
Output:
minValue: -2147483648
maxValue: 2147483647