max value of integer

In Java, the maximum value of an int type is 2147483647. This is the highest positive number that can be represented with a 32-bit binary number.

You can use the Integer.MAX_VALUE constant to get the maximum value of an int in your Java program:

int max = Integer.MAX_VALUE; // max will be 2147483647

You can also use the Integer.MIN_VALUE constant to get the minimum value of an int, which is -2147483648.

int min = Integer.MIN_VALUE; // min will be -2147483648

Note that the int type has a minimum value of -2147483648 and a maximum value of 2147483647. If you try to assign a value outside of this range to an int variable, you will get an integer overflow or underflow.

If you need to store numbers that are larger than the maximum value of an int, you can use the long type, which has a minimum value of -9223372036854775808 and a maximum value of 9223372036854775807. You can use the Long.MAX_VALUE and Long.MIN_VALUE constants to get the maximum and minimum values of a long in your Java program.