EN
Java - min and max short value (short range)
6 points
In this short article, we would like to show what is min and max short
value in Java.
Quick solution:
Short in Java is in range from
-32768
to32767
.
xxxxxxxxxx
1
short minValue = Short.MIN_VALUE; // -32768
2
short maxValue = Short.MAX_VALUE; // 32767
Hint:
Short
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
short minValue = Short.MIN_VALUE; // -32768
6
short maxValue = Short.MAX_VALUE; // 32767
7
8
System.out.println("minValue: " + minValue); // minValue: -32768
9
System.out.println("maxValue: " + maxValue); // maxValue: 32767
10
}
11
}
Output:
xxxxxxxxxx
1
minValue: -32768
2
maxValue: 32767