You are here: Home / Topics / Nested if-else example in Java

Nested if-else example in Java

Filed under: Java on 2023-08-12 20:44:38

// Program to find Maximum of Three numbers using Nested-If.

class Max3IfElse
{
public static void main( String args[] )
{
 int a, b, c, max;

 a = 23;
 b = 93;
 c = 10;

 if( a > b )
 {
  if( a > c )
   max = a;
  else
   max = c;
        }
 else
 {
  if( b > c )
   max = b;
  else
   max = c;
 }
 
 System.out.println("\nMaximum : " + max );
}
}


Output:

Maximum : 93

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.