Java Program for Minimum and Maximum values of datatype int

Data Types in Java include the byte, short, boolean, int, long, float, double and char type. Every Java Datatype has a range, i.e. represented by a minimum and maximum value.

Maximum value of Integer:

Minimum value of Integer:

Example 1

Following is an example to display the minimum and maximum value of int datatype:

Output

Example 2

Following is an example to check for Integer Overflow with the maximum and minimum values of datatype int:

Output

On incrementing MAX_VALUE, it results in MIN_VALUE for Integer type in Java as shown above. Java handles overflow accordingly for Integer type.

Java Program to check for Integer Overflow
Java Program to get maximum of three integer values
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading