Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples Last Updated : 22 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Most of the times, in competitive programming, there is a need to assign the variable, the maximum or minimum value that data type can hold, but remembering such a large and precise number comes out to be a difficult job. Therefore, Java has constants to represent these numbers, so that these can be directly assigned to the variable without actually typing the whole number. Integer.MAX_VALUE Integer.MAX_VALUE is a constant in the Integer class of java.lang package that specifies that stores the maximum possible value for any integer variable in Java. The actual value of this is 2^31-1 = 2147483647 Example 1: Java // Java program to show // the value of Integer.MAX_VALUE class GFG { // Driver code public static void main(String[] arg) { // Print the value of Integer.MAX_VALUE System.out.println("Integer.MAX_VALUE = " + Integer.MAX_VALUE); } } Output: Integer.MAX_VALUE = 2147483647 Any integer variable cannot store any value beyond this limit. Upon doing so, the memory will overflow and the value will get negative. Example 2: Trying to initialize a variable value Integer.MAX_VALUE + 1 Java // Java program to show what happens when // a value greater than Integer.MAX_VALUE // is stored in an int variable class GFG { // Driver code public static void main(String[] arg) { try { System.out.println( "Trying to initialize" + " a N with value" + " Integer.MAX_VALUE + 1"); // Try to store value Integer.MAX_VALUE + 1 int N = Integer.MAX_VALUE + 1; // Print the value of N System.out.println("N = " + N); } catch (Exception e) { System.out.println(e); } } } Output: Trying to initialize a N with value Integer.MAX_VALUE + 1 N = -2147483648 Integer.MIN_VALUE Integer.MIN_VALUE is a constant in the Integer class of java.lang package that specifies that stores the minimum possible value for any integer variable in Java. The actual value of this is -2^31 = -2147483648 Example 3: Java // Java program to show // the value of Integer.MIN_VALUE class GFG { // Driver code public static void main(String[] arg) { // Print the value of Integer.MIN_VALUE System.out.println("Integer.MIN_VALUE = " + Integer.MIN_VALUE); } } Output: Integer.MIN_VALUE = -2147483648 Any integer variable cannot store any value below this limit. Upon doing so, the memory will overflow and the value will get positive. Example 2: Trying to initialize a variable value Integer.MIN_VALUE - 1 Java // Java program to show what happens when // a value less than Integer.MIN_VALUE // is stored in an int variable class GFG { // Driver code public static void main(String[] arg) { try { System.out.println( "Trying to initialize" + " a N with value" + " Integer.MIN_VALUE - 1"); // Try to store value Integer.MIN_VALUE - 1 int N = Integer.MIN_VALUE - 1; // Print the value of N System.out.println("N = " + N); } catch (Exception e) { System.out.println(e); } } } Output: Trying to initialize a N with value Integer.MIN_VALUE - 1 N = 2147483647 Comment More infoAdvertise with us Next Article Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples C code_r Follow Improve Article Tags : Java Java-Integer Practice Tags : Java Similar Reads ValueRange isIntValue() method in Java with Examples The isIntValue() method of ValueRange class is used to check if all values in the ValueRange fit in an int. This method validates that all valid values are within the bounds of an integer or not. Syntax: public boolean isIntValue() Parameters: This method accepts nothing. Return value: This method r 1 min read IntStream min() in Java with Examples java.util.stream.IntStream in Java 8, deals with primitive ints. It helps to solve the old problems like finding maximum value in array, finding minimum value in array, sum of all elements in array, and average of all values in array in a new way. IntStream min() returns an OptionalInt describing th 2 min read IntStream max() in Java with examples java.util.stream.IntStream in Java 8, deals with primitive ints. It helps to solve the problems like finding maximum value in array, finding minimum value in array, sum of all elements in array, and average of all values in array in a new way. IntStream max() returns an OptionalInt describing the ma 2 min read ValueRange getMinimum() method in Java with Examples The getMinimum() method of ValueRange class is used to get the minimum value that the valueRange can take. For example, the ChronoField DAY_OF_WEEK always starts at 1. The minimum is therefore 1. Syntax: public long getMinimum() Parameters: This method accepts nothing. Return value: This method retu 1 min read ValueRange of() method in Java with Examples The of() method of ValueRange class helps us to Obtains value range based on parameters passed to it. There are three types of of() methods based on parameters passed to it. of(long min, long max): This method help us to get a fixed value range where the minimum and maximum values are fixed. Syntax: 3 min read Difference between an Integer and int in Java with Examples In Java, int is a primitive data type while Integer is a Wrapper class.int, being a primitive data type has got less flexibility. We can only store the binary value of an integer in it.Since Integer is a wrapper class for int data type, it gives us more flexibility in storing, converting and manipul 6 min read Level intValue() method in Java with Examples The intValue() method of java.util.logging.Level is used to get the integer value for this level object. Every level has an integer value associated with it. This integer value can be used for efficient ordering comparisons between Level objects. This method is helpful if we want to use the int valu 2 min read Number.shortValue() method in java with examples The shortValue() is an inbuilt method in Java from the java.lang.Number class. This method is used to convert the current number object into a short primitive type. This may involve rounding or truncation because the short data type in Java is a 16-bit signed integer with a value range from -32,768 2 min read ValueRange toString() method in Java with Examples The toString() method of ValueRange class is used to return this ValueRange as a String in format '{min}/{largestMin} - {smallestMax}/{max}', where the largestMin or smallestMax sections may be omitted, together with associated slash, if they are the same as the min or max. Syntax: public String toS 1 min read Number.intValue() method in java with examples The intValue() is an inbuilt method provided by the abstract class java.lang.Number. This method converts a numeric object, such as Float, Double, etc., to an int type. This method may involve rounding or truncation if the original number is a floating-point value.Syntax of Number.intValue() Methodp 2 min read Like