You are here: Home / Topics / Nested if example in Java

Nested if example in Java

Filed under: Java on 2023-08-12 20:43:55

//  Nested if example

public class NestedIf{

  public static void main(String[] args) {
  int a = 10;
  
  if(a>0){
      if(a<=10){
          System.out.println("a --> 0 to 10");
      }
      
      if(a>10 && a<=20){
          System.out.println("a --> 11 to 20");
      }
      
      if(a>20){
          System.out.println("a --> 21 to ((2^31 -1)= 2,14,74,83,647");
      }
  }
}
}

 

Output:

a --> 0 to 10

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