- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display the limits of DataTypes in Java
Every data type in Java has a minimum as well as maximum range, for example, for Integer.
Minimum = -2147483648 Maximum = 2147483647
Let’s say for Integer, if the value extends the maximum range display above, it leads to Overflow. However, if the value is less than the minimum range displayed above, it leads to Underflow.
The following program displays the limits on datatypes in Java.
Example
public class Demo { public static void main(String[] args) { System.out.println("Limits of primitive DataTypes"); System.out.println("Byte Datatype values..."); System.out.println("Min = " + Byte.MIN_VALUE); System.out.println("Max = " + Byte.MAX_VALUE); System.out.println("Short Datatype values..."); System.out.println("Min = " + Short.MIN_VALUE); System.out.println("Max = " + Short.MAX_VALUE); System.out.println("Integer Datatype values..."); System.out.println("Min = " + Integer.MIN_VALUE); System.out.println("Max = " + Integer.MAX_VALUE); System.out.println("Float Datatype values..."); System.out.println("Min = " + Float.MIN_VALUE); System.out.println("Max = " + Float.MAX_VALUE); System.out.println("Double Datatype values..."); System.out.println("Min = " + Double.MIN_VALUE); System.out.println("Max = " + Double.MAX_VALUE); } }
Output
Limits of primitive DataTypes Byte Datatype values... Min = -128 Max = 127 Short Datatype values... Min = -32768 Max = 32767 Integer Datatype values... Min = -2147483648 Max = 2147483647 Float Datatype values... Min = 1.4E-45 Max = 3.4028235E38 Double Datatype values... Min = 4.9E-324 Max = 1.7976931348623157E308
In the above program, we have taken each datatype one by one and used the following properties to get the minimum and maximum values. For example, datatype Byte.
Byte.MIN_VALUE; Byte.MAX_VALUE
The above returns the minimum and maximum value of Byte datatype. In the same way, it works for other datatypes.
Min = -128 Max = 127
- Related Articles
- Display default initial values of DataTypes in Java
- Overflow of DataTypes in Java
- Underflow of DataTypes in Java
- Write a C program to display all datatypes ranges in tabular form
- Python – Get the datatypes of columns
- Limits of Conflict Resolution
- Explain the meaning of the following terms:Class limits
- Python Container Datatypes
- What is the C# Equivalent of SQL Server DataTypes?
- Display the maximum amount of memory in Java
- Display the position of a Substring in Java
- Display the length of current file in Java
- Explain the meaning of the following terms:True class limits.
- What is the basic terminology in the system of limits and fits?
- Display three-digit day of the year in Java

Advertisements