Integer sign
In this chapter you will learn:
Get the sign of an Integer
static int signum(int i)
returns the signum.
The possible values returned from signum(int i)
are listed below:
Value | Meaning |
---|---|
-1 | if i is negative; |
0 | if i is zero; |
1 | if i is positive. |
In the following code we pass in constant value 10 to signum(int i)
.
public class Main {
public static void main(String[] args) {
/*from ja va 2s . c o m*/
System.out.println(Integer.signum(10));
}
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » Primitive Data Types