# How do I get the minimum and maximum value of a primitive data types?

To get the minimum or maximum value of a primitive data types such as `byte`, `short`, `int`, `long`, `float` and `double` we can use the wrapper class provided for each of them, the wrapper classes are `Byte`, `Short`, `Integer`, `Long`, `Float` and `Double` which is located in `java.lang` package.

``````package org.kodejava.lang;

public class MinMaxExample {
public static void main(String[] args) {
System.out.println("Byte.MIN    = " + Byte.MIN_VALUE);
System.out.println("Byte.MAX    = " + Byte.MAX_VALUE);
System.out.println("Short.MIN   = " + Short.MIN_VALUE);
System.out.println("Short.MAX   = " + Short.MAX_VALUE);
System.out.println("Integer.MIN = " + Integer.MIN_VALUE);
System.out.println("Integer.MAX = " + Integer.MAX_VALUE);
System.out.println("Long.MIN    = " + Long.MIN_VALUE);
System.out.println("Long.MAX    = " + Long.MAX_VALUE);
System.out.println("Float.MIN   = " + Float.MIN_VALUE);
System.out.println("Float.MAX   = " + Float.MAX_VALUE);
System.out.println("Double.MIN  = " + Double.MIN_VALUE);
System.out.println("Double.MAX  = " + Double.MAX_VALUE);
}
}
``````

The result of the code above shows the minimum and maximum value for each data types.

``````Byte.MIN    = -128
Byte.MAX    = 127
Short.MIN   = -32768
Short.MAX   = 32767
Integer.MIN = -2147483648
Integer.MAX = 2147483647
Long.MIN    = -9223372036854775808
Long.MAX    = 9223372036854775807
Float.MIN   = 1.4E-45
Float.MAX   = 3.4028235E38
Double.MIN  = 4.9E-324
Double.MAX  = 1.7976931348623157E308
``````

This site uses Akismet to reduce spam. Learn how your comment data is processed.