Java if statements is used to execute some code, if a condition is true otherwise if condition is false, execute nothing.
Syntax:
![java-if](https://www.w3schools.in/wp-content/uploads/2014/07/c-if.png)
Example:
public class Sample{
public static void main(String args[]){
int a=20, b=30;
if(b>a)
System.out.println("b is greater");
}
}
Program Output:
![java-if-statements](https://www.w3schools.in/wp-content/uploads/2015/07/java-if-statements.jpg)
No comments:
Post a Comment