Learn Java , Selenium

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

ย 

Scroll to Top