Java program to find largest of three numbers using nested if. 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.
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
Java program for nested if
An if statement that is the target of another if or otherwise is known as a nested if. An if statement inside an if statement is referred to as nested if statements. Yes, we may stack if statements within if statements in Java. The final else line will be executed if none of the conditions are true.
What is 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.