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
.
xxxxxxxxxx
1
int minValue = Integer.MIN_VALUE; // -2147483648
2
int maxValue = Integer.MAX_VALUE; // 2147483647
Hint:
Integer
class is located injava.lang
package and is imported automatically.
xxxxxxxxxx
1
public class Program {
2
3
public static void main(String[] args) {
4
5
int minValue = Integer.MIN_VALUE; // -2147483648
6
int maxValue = Integer.MAX_VALUE; // 2147483647
7
8
System.out.println("minValue: " + minValue); // minValue: -2147483648
9
System.out.println("maxValue: " + maxValue); // maxValue: 2147483647
10
}
11
}
Output:
xxxxxxxxxx
1
minValue: -2147483648
2
maxValue: 2147483647