A programming language uses control statements to control the flow of execution of a program. In Java programming, we can control the flow of execution of a program based on some conditions. Java control statements can be put into the following three categories: selection, iteration, and jump.
Output:
you may also like these related posts:
8. Java Hashtable with example.
9. Java constructor with example.
10. Exception handling in java with example.
Java if Statement:
if statement in Java is a simple decision-making statement. Java if statement is used to decide whether a certain statement or block of the statement will be executed or not. If a certain condition is true, then the block of statement is executed, otherwise not.
Syntax:
if(condition){
//statement to be execute.
//if condition is true.
}
Flowchart:
Java if statement Example:
class ifExample{
public static void main(String args[]){
int a = 10;
if( a > 5){
System.out.println("If block executed");
}
}
}
Output:
if block executed
you may also like these related posts:
1. Types of Operators in Java with example.
2. Basic data types in Java with example.
3. How to set path in java.
4. Types of variables in Java with example.
5. Java Hello World program | java first program.
6. Top 100 java interview question and answer.
7. Java Collection framework complete tutorial.2. Basic data types in Java with example.
3. How to set path in java.
4. Types of variables in Java with example.
5. Java Hello World program | java first program.
6. Top 100 java interview question and answer.
8. Java Hashtable with example.
9. Java constructor with example.
10. Exception handling in java with example.
Java if Statement with Example
Reviewed by Prashant Srivastava
on
December 16, 2019
Rating:
No comments: