Java Program to Find the Largest Number Among Three Numbers

This is a Java Program to Find the Biggest of 3 Numbers.

Enter any three integer numbers as an input. Now we check the first number against the second and third number. If it false then we check for second number against third. If it is also false then accordingly third number will be declared the largest number of the given three numbers.

Here is the source code of the Java Program to Find the Biggest of 3 Numbers. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

  1. import java.util.Scanner;
  2. public class Biggest_Number 
  3. {
  4.     public static void main(String[] args) 
  5.     {
  6.         int x, y, z;
  7.         Scanner s = new Scanner(;
  8.         System.out.print("Enter the first number:");
  9.         x = s.nextInt();
  10.         System.out.print("Enter the second number:");
  11.         y = s.nextInt();
  12.         System.out.print("Enter the third number:");
  13.         z = s.nextInt();
  14.         if(x > y && x > z)
  15.         {
  16.             System.out.println("Largest number is:"+x);
  17.         }
  18.         else if(y > z)
  19.         {
  20.             System.out.println("Largest number is:"+y);
  21.         }
  22.         else
  23.         {
  24.             System.out.println("Largest number is:"+z);
  25.         }
  27.     }
  28. }


$ javac
$ java Biggest_Number
Enter the first number:10
Enter the second number:17
Enter the third number:15
Largest number is:17

Sanfoundry Global Education & Learning Series –- 1000 Java Programs.


Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.