Greatest of Three Numbers in Java Using Nested If

Greatest of three numbers in java. In java programming for beginners, the largest number program compares numbers to select the largest number in a given number. This program will check the which is largest number among these three.

Double Value in Java

A primitive data type in Java is the double keyword. It’s a 64-bit IEEE 754 floating-point with double precision. It’s where variables and methods are declared. 

It is used to represent decimal numbers in general. Floating-point numbers are represented using a Java double. It has a range that is larger than the float type and utilizes 64 bits to hold a variable value.

If Else Statement in Java

The conditional statements in Java are as follows: If a particular condition is true, use if to specify a block of code to be run. If the same condition is false, use otherwise to define a block of code to run. If the initial condition is false, use else if to provide a new condition to test. 

The if block will be performed if the Boolean statement evaluates to true; else, the else block will be executed. Any non-zero and non-null values are presumed to be true in the C programming language, whereas zero and null values are believed to be false.

If Else Ladder Statement in Java

To choose amongst many choices, a Java if-else-if ladder is utilized. From the top-down, the if statements are performed. The statement linked with that if is performed as soon as one of the criteria controlling the if is true, and the rest of the ladder is bypassed.

public class Main
public static void main(String[] args) 
double a = 500, b = 1000, c = 1500;
if( a >= b && a >= c)
System.out.println(a + " largest number");
else if (b >= a && b >= c)
System.out.println(b + " largest number");
System.out.println(c + " largest number");


1500 is largest number