Java Integer.signum(int i)

Syntax

Integer.signum(int i) has the following syntax.

public static int signum(int i)

Example

In the following code shows how to use Integer.signum(int i) method.


//from www.ja  va 2s  .c om

public class Main {
   public static void main(String[] args) {

     // returns 1 as int value is greater than 1
     System.out.println(Integer.signum(5));
      
     // returns -1 as int value is less than 1
     System.out.println(Integer.signum(-5));
     
     // returns 0 as int value is equal to 0
     System.out.println(Integer.signum(0));
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable