codeGK
Code it ALL
Java If Else - CodeGK
Δ JAVA Tutorial
♦ Java If Else

♣ About Java If Else

if, else-if, and else are conditional statements.
Deterministic decisions can be made through this literals.

♣ Conditionals in Java

Conditionals provide boolean value as output, upon which further comparison can be done.
Conditionals occur two compare same Data Types over operators, such as:-
Table Info
Descriptionoperation
Greater Thana > b
Greater Than or Equal toa >= b
Less Thana < b
Less Than or Equal toa <= b
Equal toa == b
Not Equal toa != b

♣ Example1: If in Java

"if" code block is executed when the corresponding if condition block is holding boolean value true.
In this example, .
Example
Input:
Output:

♣ Example2: Else in Java

"else" condition is executed if all prior conditions are false. In this example, .
Example
Input:
Output:

♣ Example3: Else-If in Java

"else if" keyword is Java's interpretation as "if the previous conditions were not true, then try current given condition". In this example, .
Example
Input:
Output:
Prev_LessonNext_Lesson