Java If Else Condition Example


Java if statement is used to check condition whether it is true or false. If the condition is true then it will run inner code, if it is false then nothing will be run.

Program
public class Ifcondition{ public static void main(String args[]){ int x=5; if(x<6){ System.out.println("x is smaller than 6"); } if(x<3){ System.out.println("x is smaller than 3"); } }}
Input
Output