Languages
[Edit]
EN

Java - min and max byte value (byte range)

4 points
Created by:
Payne
654

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 to 127.

byte minValue = Byte.MIN_VALUE;  // -128
byte maxValue = Byte.MAX_VALUE;  //  127

 

Practical example

Hint: Byte class is located in java.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

 

See also

  1. Java - min and max short value

  2. Java - min and max int value

  3. Java - min and max long value

Alternative titles

  1. Java - byte value range
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join