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