a concise shot of dev knowledge
Become a Contributor
Concise shots of dev knowledge

RELATED TAGS

java
communitycreator

What is Integer.MIN_VALUE in Java?

abhilash

What are integers?

Integers are numbers that can be written without a fractional component. For example, 100, 200, 423, and 123 are integers, while 8.32, 5+1/2, -23.2 are not.

In Java, integers are represented in two’s complement binary form, with each number taking up 32 bits. We can encode that many values in 32 bits of space, where one bit represents the sign.

Integer.MIN_VALUE

The Integer.MIN_VALUE is a constant in the Integer class that represents the minimum or least integer value that can be represented in 32 bits, which is -2147483648, -231. This is the lowest value that any integer variable in Java can hold.

public class Main {

    public static void main(String[] args){
        System.out.println("Integer.MIN_VALUE= "+ Integer.MIN_VALUE);
    }
}

Any value less than Integer.MIN_VALUE will lead to an overflow in memory and will be a positive value.

public class Main {

    public static void main(String[] args){
        System.out.println("(Integer.MIN_VALUE-1)= "+ (Integer.MIN_VALUE-1));
    }
}

RELATED TAGS

java
communitycreator
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time

Copyright ©2022 Educative, Inc. All rights reserved.

soc2