Conditional Statement in Java – if else Statement –ย
package practice;
public class IfElse {
public static void main(String[] args) {
int x = 20;
int y = 18;
if (x >= y) {
System.out.println("x is greater than or equal to y");
} else {
System.out.println("x is less than y");
}
int z = 50 ;
if ( z == 51) {
System.out.println("z is equal to 50");
}else {
System.out.println("z is not equal to 50");
}
}
}
๐งพ Explanation:
This program demonstrates the use of if-else conditional statements in Java.
โ
First Condition:
x = 20, y = 18
x >= y is true, so it prints:
x is greater than or equal to y
โ
Second Condition:
z = 50
z == 51 is false, so it prints:
z is not equal to 50
ย