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:
- import java.io.*;
- class Main {
- public static void main (String[] args) {
- int i = 1;
- if( i % 2 != 0)
- {
- System.out.println("i is odd number.");
- }
- }
- }
Output:
i is odd number.
Here is the Video: