You are here: Home / Topics / Simple If statement example in Java 2

Simple If statement example in Java 2

Filed under: Java on 2023-08-12 20:40:31

// Simple if example

public class SimpleIf{

   public static void main(String[] args) {
       int a = 10;
       int b = 20;
       
       if(a>b){
           System.out.println("a is greater than b");
       }
       
       if(a<b){
           System.out.println("a is less than b");
       }
       
       if(a==b){
           System.out.println("a is equal to b");
       }
   }
}


Output:

a is less than b

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.