How to Use If Statement in Java


In this example we will show you how to use the if statement in Java.

Source Code

package com.beginner.examples;

public class If {
  public static void main(String[] args) {
    if (2 > 1) { // use the if statement
      System.out.println("OK"); 
    }
  }
}

Output:

OK
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments