If Statement in Java
What is if statement in Java?
If statement is conditional statement in Java. It is used to check the condtion given to it.
Syntax of if statement...
if(condition)
{
//number of statements
}
Example of if statement in Java:
//Java Program of if statement.
public class IfStatement
{
public static void main(String[] args)
{
int num=10; //initializing a variable.
if(num>5) //checking the condition.
{
System.out.println("Welcome to Compuhelp");
}//end of if statement
} //end of main method
}//end of class IfStatement
Output
Welcome to Compuhelp
Description:
In the above example, the if block will get excecuted because, the condition given in the if statement is will be true because, the variable num containing value greater than 5.