How to find the Minimum of Three Numbers in Java - Step by Step Examples



How to find the Minimum of Three Numbers in Java ?

Answer

To find the minimum of three numbers in Java, you can use a simple if-else statement.



✐ Examples

1 Find Minimum of Three Numbers

In this example,

  1. We declare three variables a, b, and c with the numbers to compare.
  2. We use a series of if-else statements to compare the numbers and update the minimum accordingly.

Java Program

public class Main {
    public static void main(String[] args) {
        int a = 5;
        int b = 8;
        int c = 3;
        int min = a;
        if (b < min) {
            min = b;
        }
        if (c < min) {
            min = c;
        }
        System.out.println("Minimum of three numbers is: " + min);
    }
}

Output

Minimum of three numbers is: 3

Summary

In this tutorial, we learned How to find the Minimum of Three Numbers in Java language with well detailed examples.




More Java Comparison Operations Tutorials

  1. How to find the Maximum of Two Numbers in Java ?
  2. How to find the Minimum of Two Numbers in Java ?
  3. How to find the Maximum of Three Numbers in Java ?
  4. How to find the Minimum of Three Numbers in Java ?