Java Integer compareUnsigned() Method25 Mar 2025 | 3 min read The 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 |
Java Integer reverseBytes Method The reverseBytes() method of Java Integer class numerically returns the value obtained by reversing the order of the bytes in the 2's complement binary representation of the specified integer value. Syntax: Following is the declaration of reverseBytes() method: public static int reverseBytes(int i) Parameter: DataType Parameter Description Required/Optional int i Integer value whose...
2 min read
Java Method The max() is a method of Integer class under Java.lang package. This method numerically returns the maximum value between the two method arguments specified by a user. This method can be overloaded and it takes the arguments in int, double, float and long....
2 min read
Java Method The divideUnsigned() is a method of Java Integer class which returns the unsigned quotient of dividing the first argument by the second argument where each argument and the result is interpreted as an unsigned value. Syntax: Following is the declaration of divideUnsigned() method: public static int...
2 min read
Java Method The reverse() method of Java Integer class numerically returns the value obtained by reversing the order of the bits in the 2's complement binary representation of the specified integer value. Syntax: Following is the declaration of reverse() method: public static int reverse(int i) Parameter: DataType Parameter Description Required/Optional int i Integer value whose bits...
2 min read
Java Method The rotateRight() method of Java Integer class returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits. (Bits shifted out of the right hand, or low-order). Bit shifting is a bitwise...
3 min read
Java Method The shortValue() method of Java Integer class returns the value of this Integer as a short type after a primitive conversion. It overrides the shortValue() method of Number Class. Syntax: Following is the declaration of shortValue() method: public static int shortValue() Parameter: DataType Parameter Description NA NA This method does not take any...
2 min read
Java Method The numberOfLeadingZeros() method is a method of Integer class under java.lang package. This method returns the total number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified integer value i.e. it converts int value to...
2 min read
Java method The decode() method is a static method of Integer class under java.lang package. The main function of this method is to decode a string which is written in the form of (" ") into an integer value. The decode() method also accepts decimal, hexadecimal,...
2 min read
This method is used to get an unsigned String object representing the value of the Number Object. There is two different types of Java toUnsignedString() method which can be differentiated depending on its parameter. These are: Java Integer toUnsignedString(int i) Method Java Integer toUnsignedString(int i, int radix) Method 1....
3 min read
Java Method The toOctalString() method of Integer class returns a string representation of the integer argument as an unsigned integer in octal base 8. The following characters are used as octal digits: 0 1 2 3 4 5 6 7 Note: If the argument is negative, the unsigned...
2 min read
We request you to subscribe our newsletter for upcoming updates.
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