- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 minimum of three integer values in Java
The following is an example displaying the minimum of three integer values.
Example
public class Demo { public static void main(String[] args) { int val1 = 99; int val2 = 87; int val3 = 130; System.out.println("Number 1 = "+val1); System.out.println("Number 2 = "+val2); System.out.println("Number 3 = "+val3); if (val2 < val1) { val1 = val2; } if (val3 < val1) { val1 = val3; } System.out.println("The smallest of three numbers: "+val1); } }
Output
Number 1 = 99 Number 2 = 87 Number 3 = 130 The smallest of three numbers: 87
In the above program, we have taken three integer variables, which will be compared.
int val1 = 99; int val2 = 87; int val3 = 130;
Now condition is used to check which of the integer value is the smallest.
if (val2 < val1) { val1 = val2; } if (val3 < val1) { val1 = val3; }
The above returns the smallest value.
- Related Articles
- Display the maximum of three integer values in Java
- Java program to get the minimum of three long values
- Display Minimum and Maximum values of datatype int in Java
- Display three-digit day of the year in Java
- Java Program to display Bit manipulation in Integer
- Display the minimum and maximum value of primitive data types in Java
- Display default initial values of DataTypes in Java
- Define integer literals as octal values in Java
- Java Program to get the maximum of three long values
- Sorting contents of a string that holds integer values in Java
- Display MySQL table values using Java
- Middle of three using minimum comparisons in C++
- Ignore null values in MySQL and display rest of the values
- Select distinct values from three columns and display in a single column with MySQL
- Display three letter-month value with SimpleDateFormat('MMM') in Java

Advertisements