If-Else

Let's write a simple code below

int x = 20; int y = 18;

if (x > y) {

System.out.println("x is greater than y");

} else {

System.out.println("Good evening.");

}

Result : x is greater than y

The code explanation is below

int x = 20; int y = 18; -> assign each of data type value

if (x > y) -> statement put as x bigger than y

System.out.println("x is greater than y"); -> if true then this statement will be executed

else -> to indicate other than main result

System.out.println("Good evening."); -> if not true then this statement will be executed

what is If-Else? if else is the conditional statement with the known data variable with the exact output by true or false that meet the output of the conditional statement.