Because the integer overflows. When it overflows, the next value is Integer.MIN_VALUE. Relevant JLS

If an integer addition overflows, then the result is the low-order bits of the mathematical sum as represented in some sufficiently large two's-complement format. If overflow occurs, then the sign of the result is not the same as the sign of the mathematical sum of the two operand values.

Answer from Bozho on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-max_value-and-integer-min_value-in-java-with-examples
Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples - GeeksforGeeks
July 12, 2025 - 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.
🌐
Code Like A Girl
code.likeagirl.io › what-happens-when-you-add-1-to-integer-max-value-in-java-09020d0906a7
What Happens When You Add 1 to Integer.MAX_VALUE in Java | by Nouhaila El Ouadi | Code Like A Girl
October 23, 2024 - If you’ve ever worked with Java’s primitive types, you’ve probably encountered Integer.MAX_VALUE. It represents the largest possible value an int can hold 2,147,483,647. One day, I decided to add 1 to it.
Top answer
1 of 11
450

In C, the language itself does not determine the representation of certain datatypes. It can vary from machine to machine, on embedded systems the int can be 16 bit wide, though usually it is 32 bit.

The only requirement is that short int <= int <= long int by size. Also, there is a recommendation that int should represent the native capacity of the processor.

All types are signed. The unsigned modifier allows you to use the highest bit as part of the value (otherwise it is reserved for the sign bit).

Here's a short table of the possible values for the possible data types:

          width                     minimum                         maximum
signed    8 bit                        -128                            +127
signed   16 bit                     -32 768                         +32 767
signed   32 bit              -2 147 483 648                  +2 147 483 647
signed   64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807
unsigned  8 bit                           0                            +255
unsigned 16 bit                           0                         +65 535
unsigned 32 bit                           0                  +4 294 967 295
unsigned 64 bit                           0     +18 446 744 073 709 551 615

In Java, the Java Language Specification determines the representation of the data types.

The order is: byte 8 bits, short 16 bits, int 32 bits, long 64 bits. All of these types are signed, there are no unsigned versions. However, bit manipulations treat the numbers as they were unsigned (that is, handling all bits correctly).

The character data type char is 16 bits wide, unsigned, and holds characters using UTF-16 encoding (however, it is possible to assign a char an arbitrary unsigned 16 bit integer that represents an invalid character codepoint)

          width                     minimum                         maximum

SIGNED
byte:     8 bit                        -128                            +127
short:   16 bit                     -32 768                         +32 767
int:     32 bit              -2 147 483 648                  +2 147 483 647
long:    64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807

UNSIGNED
char     16 bit                           0                         +65 535
2 of 11
84

In C, the integer(for 32 bit machine) is 32 bit and it ranges from -32768 to +32767.

Wrong. 32-bit signed integer in 2's complement representation has the range -231 to 231-1 which is equal to -2,147,483,648 to 2,147,483,647.

🌐
iO Flood
ioflood.com › blog › integer-max-value-java
Java's Integer.MAX_VALUE Explained: A Complete Guide
March 11, 2024 - The reason lies in how integers are represented in binary form in computer systems. An integer in Java is represented by 32 bits, and when all these bits are set to 1, the decimal equivalent is 2,147,483,647.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_SAFE_INTEGER
Number.MAX_SAFE_INTEGER - JavaScript | MDN
Number.EPSILON is 2-52, while MAX_SAFE_INTEGER is 253 – 1 — both of them are derived from the width of the mantissa, which is 53 bits (with the highest bit always being 1). Multiplying them will give a value very close — but not equal — to 2.
🌐
TutorialsPoint
tutorialspoint.com › integer-max-value-and-integer-min-value-in-java-with-examples
Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples
The Integer class of Java provides two constants named Integer.MAX_VALUE and Integer.MIN_VALUE represents the maximum and minimum possible values for an integer variable in Java. The actual value of Integer.MAX_VALUE is 231 -1 which is equivalent to
🌐
CodeGym
codegym.cc › java blog › java numbers › integer max_value in java with examples
Integer MAX_VALUE in Java with Examples
December 10, 2024 - Integer.MAX_VALUE is a number in the Java Integer сlass of java.lang package. It is the maximum possible Integer number that can be represented in 32 bits. Its exact value is 2147483647 i.e. 2^31-1.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 6 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 6)
A constant holding the maximum value an int can have, 231-1. ... The Class instance representing the primitive type int. ... The number of bits used to represent an int value in two's complement binary form. ... Constructs a newly allocated Integer object that represents the specified int value.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › maximum-value-of-int-in-c
Maximum value of int in C++ - GeeksforGeeks
July 23, 2025 - Takes a size of 32 bits where 1 bit is used to store the sign of the integer. A maximum integer value that can be stored in an int data type is typically 2, 147, 483, 647, around 231 - 1, but is compiler dependent.
🌐
Educative
educative.io › answers › what-is-integermaxvalue
What is Integer.MAX_VALUE?
If the first bit is 1 and all the other 31 bits are 0 then the number will be the maximum negative number. ... Integer.MAX_VALUE represents the maximum positive integer value that can be represented in 32 bits (i.e., 2147483647).
🌐
Reddit
reddit.com › r/java › why integer.max_value + integer.max_value result in -2?
r/java on Reddit: Why Integer.MAX_VALUE + Integer.MAX_VALUE result in -2?
May 16, 2013 -

I tried this (Java 1.4):

int result = Integer.MAX_VALUE + Integer.MAX_VALUE;
system.out.println(result); // -2 

What I understand so far about Integer in Java:

  • Integer.MAX_VALUE is 2 ^ 31 - 1 and Integer.MIN_VALUE is -(2 ^ 31)

  • -Integer.MIN_VALUE will result to Integer.MIN_VALUE because 2 ^ 31 is simply greater than 2 ^ 31 - 1 which makes the integer overflow to Integer.MIN_VALUE again

But I still cannot wrap my head around why (231 - 1) + (231 - 1) = -2 ?

What I'm trying to achieve here is to understand why Integer.MAX_VALUE and Integer.MIN_VALUE is sometimes used in Comparator to implement a > b > c

a.compareTo(b) + b.compareTo(c) <= a.compareTo(c)

Thank you. :)

🌐
Runestone Academy
runestone.academy › ns › books › published › apcsareview › VariableBasics › minAndMax.html
3.7. Integer Min and Max — AP CSA Java Review - Obsolete
Why is there one more negative number than positive number? It is because 0 is considered a positive number. What do the last two lines print out? Did this surprise you? Java will actually return the maximum integer value if you try to subtract one from the minimum value.
🌐
Reddit
reddit.com › r/learnjava › why does 2 * integer.max_value return -2?
r/learnjava on Reddit: Why does 2 * Integer.MAX_VALUE return -2?
May 21, 2022 -

I know that an int is a 32 bit number with a range of -2,147,483,648 to 2,147,483,647. I'm learning about overflow, and I am trying to figure out why 2 * Integer.MAX_VALUE returns -2.

Would anyone mind explaining overflow and why this is calculated this way, please?

Thank you in advance! :)

Edit: Thanks for the replies, everyone. I still don't completely understand it, but at least I have a good start to go down the rabbit hole of binary and hexadecimal numbers! :D

Edit #2: I think I get it now, and if anyone is curious this stack overflow question explains it well. Thanks again for the responses.

🌐
javaspring
javaspring.net › blog › intergermax-java
Understanding `Integer.MAX_VALUE` in Java — javaspring.net
The Integer.MAX_VALUE is a static final field of the Integer class, and its value is defined as 0x7fffffff in hexadecimal, which is equivalent to 2^31 - 1 or 2147483647 in decimal.
🌐
Wikipedia
en.wikipedia.org › wiki › 2,147,483,647
2,147,483,647 - Wikipedia
2 weeks ago - In 1811, Peter Barlow wrote (in An Elementary Investigation of the Theory of Numbers): Euler ascertained that 231 − 1 = 2147483647 is a prime number; and this is the greatest at present known to be such, and, consequently, the last of the ...
🌐
LinkedIn
linkedin.com › pulse › what-integermaxvalue-omar-ismail
What is Integer.MAX_VALUE?
August 31, 2021 - Integer.MAX_VALUE represents the maximum positive integer value that can be represented in 32 bits (i.e., 2147483647).
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 8 )
October 20, 2025 - (The return value is -1 if the specified value is negative; 0 if the specified value is zero; and 1 if the specified value is positive.) ... Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified int value.