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
.
short minValue = Short.MIN_VALUE; // -32768
short maxValue = Short.MAX_VALUE; // 32767
Practical example
Hint:
Short
class is located injava.lang
package and is imported automatically.
public class Program {
public static void main(String[] args) {
short minValue = Short.MIN_VALUE; // -32768
short maxValue = Short.MAX_VALUE; // 32767
System.out.println("minValue: " + minValue); // minValue: -32768
System.out.println("maxValue: " + maxValue); // maxValue: 32767
}
}
Output:
minValue: -32768
maxValue: 32767