Skip to main content

Conditional Statements: If Statement

Java | If Statement: If statement is one of conditional statement, it execute the code in the if block only condition is true.

Syntax :             if ( condition )
                          {
                                // statements...
                           }

Here is the Code:

  1. import java.io.*;

  2. class Main {
  3. public static void main (String[] args) {
  4.     int i = 1;
  5.     if( i % 2 != 0)
  6.     {
  7.         System.out.println("i is odd number.");
  8.     }
  9. }
  10. }

Output:
i is odd number.

Here is the Video: