If statement (Part 1)

 The If Statement

Use the if statement to specify a block of Java code to be executed if a condition is true.

Syntax:
if (condition) {   
  // block of code to be executed if the condition is true   
  } 

Flowchart:(Representation of loop in form of diagram)

If Statement

Eg:-
 public class MyClass {  
   public static void main(String args[]) {  
    int x = 10;  
    if( x < 20 ) {  
      System.out.print("This is if statement");  
    }  
   }  
 }
Output:-
 This is if statement.  



< Previous Next >