Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Minimum and Maximum values of datatype int in Java
To get the minimum value of datatype int in Java, use the following −
Integer.MIN_VALUE
To get the maximum value of datatype int in Java, use the following −
Integer.MAX_VALUE
Let us now implement this in our example.
Example
public class Demo {
public static void main(String[] args) {
int val1 = 20;
int val2 = 3000;
System.out.println("Value1: "+val1);
System.out.println("Value2: "+val2);
System.out.println("Maximum value: "+Integer.MIN_VALUE);
System.out.println("Minimum value: "+Integer.MAX_VALUE);
}
}
Output
Value1: 20 Value2: 3000 Maximum value: -2147483648 Minimum value: 2147483647
Advertisements