Skip to main content

Posts

Showing posts with the label Conditional Statements: If - Else Statement

Conditional Statements: If - Else Statement

Java | If - Else Statement: If - else statement is one of the conditional statement. if checks the condition, if condition is true if block executes otherwise else block executes. Syntax:                   if ( condition )                                {                                        // statements...                                 }                                 else                                 {                                         // statements...                                  } Here is the Code: import java.io.*; class Main { public static void main (String[] args) {     int i = 1;     if( i % 2 == 0)     {         System.out.println("Even");     }     else     {         System.out.println("Odd");     }     int a = 1, b = 2;     int min;     if( a < b )     {         min = a;     }     else     {         min = b;     }     System.out.println("Min value is :" + min); } } Output: Odd Mi