You are here: Home / Topics / Program to find whether number is positive or negative in Java

Program to find whether number is positive or negative in Java

Filed under: Java on 2023-08-12 20:47:14

// else if ladder example

public class ElseIfLadder{

   public static void main(String[] args) {
       int a = 13;

       if (a < 0) {
           System.out.println("a is negative");
       } else if (a == 0) {
           System.out.println("a is zero");
       } else if (a > 0) {
           System.out.println("a is positive");
       }
   }
}


Output:

a is positive


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