Java Integer compareUnsigned() MethodThe compareUnsigned() is a method of Java Integer class which compares two integer objects numerically treating the values as unsigned. It returns the result of the value 0 if both arguments are equal; a value less than 0, if the first argument is less than the second argument; a value greater than 0 will be returned, if the first argument is less than the second argument. This method is specified by Comparable<Integer> Interface. Note: This method cannot be compared to two different types of argument so, both the argument and the number should be the same type.Syntax:Following is the declaration of compareUnsigned() method: Parameter:
Returns:The compareUnsigned(int x, int y) method will returns the following values:
Exceptions:NA Compatibility Version:Java 1.8 and above Example 1Output: Output: 0 Output: -1 Output: 1 Output: -1 Example 2Output: x is greater than y Example 3Output: Enter the first value: -45 Enter the second value: 65 First Value is greater than the second value. Example 4Output: Campare the user inputs (unsigned integer): -44 -44 88 The Results are: 0 1 -1 Next TopicJava-integer-decode-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India