100
Java Integer Class
The Java Integer class comes under the Java.lang.Number package. This class wraps a value of the primitive type int in an object. An object of Integer class contains a single field of type int value.
Java Integer Methods
The Java Integer class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods dealing with an int. The various Java Integer methods are as follows:
SN | Modifier & Type | Method | Discription |
---|---|---|---|
1) | static int | bitCount() | It returns the number of 1-bits in the 2’s complement binary representation of the specified int value. |
2) | byte | byteValue() | It converts the given number into a primitive byte type and returns the value of integer object as byte. |
3) | Static int | compare() | It compares two int values numerically and returns the result in integer equivalent. |
4) | Int | compareTo() | It compares two integer objects numerically and returns the result as -1, 0 or 1. |
5) | static int | compareUnsigned() | It compares two integer objects numerically treating the values as unsigned and returns the result as -1, 0 or 1. |
6) | static Integer | decode() | It decodes a String object into an Integer value. |
7) | static int | divideUnsigned() | It 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. |
8) | double | doubleValue() | It converts the given Integer value and returns the result as a double equivalent. |
9) | boolean | equals() | It compares the value of the parameter to the value of the current Integer object and returns boolean ( True or False ). |
10) | float | floatValue() | It converts the given Integer value and returns the result as a float equivalent. |
11) | Static Integer | getInteger() | It determines the integer value of the system property with the specified name. |
12) | static int | hashCode() | It returns a hash code for the given Integer. |
13) | static int | highestOneBit() | It returns int value with at most a single one-bit, in the position of the highest-order (“leftmost”) one-bit in the specified int value. |
14) | static int | lowestOneBit() | It eturns int value with at most a single one-bit, in the position of the lowest-order (“rightmost”) one-bit in the specified int value. |
15) | static int | max() | It returns the maximum value amongst the two method argument. |
16) | static int | min() | It returns the minimum value amongst the two method argument. |
17) | int | intValue() | It returns the value of the specified number as an int. |
18) | long | longValue() | It returns the value of the specified long object as long equivalent. |
19) | static int | numberOfLeadingZeros() | It returns the total number of zero bits preceding the highest-order (“leftmost”) one-bit in the 2’s complement binary representation of the specified int value. |
20) | static int | numberOfTrailingZeros() | It returns the total number of zero bits following the lowest-order (“rightmost”) one-bit in the 2’s complement binary representation of the specified int value. |
21) | static int | parseInt() | It parses the String argument as a signed decimal Integer object. |
22) | static int | parseUnsignedInt() | It parses the String argument as an unsigned decimal Integer object. |
23) | static int | remainderUnsigned() | It returns the unsigned remainder from dividing the first argument by the second argument where each argument and the result is interpreted as an unsigned value. |
24) | static int | reverse() | It returns the value obtained by reversing the order of the bits in the 2’s complement binary representation of the specified int value. |
25) | static int | reverseBytes() | It returns the value obtained by reversing the order of the bytes in the 2’s complement binary representation of the specified int value. |
26) | static int | rotateLeft() | It returns the value obtained by rotating the 2’s complement binary representation of the specified int value left by the specified number of bits. |
27) | static int | rotateRight() | It returns the value obtained by rotating the 2’s complement binary representation of the specified int value right by the specified number of bits. |
28) | short | shortValue() | It returns the value of this Integer as a short type after a primitive conversion. |
29) | static int | signum() | It returns the signum function of the specified int value. |
30) | static int | sum() | It returns the sum by adding two integers together as per the + operator. |
31) | static String | toBinaryString() | It returns a string representation of the integer argument as an unsigned integer in binary base 2. |
32) | static String | toHexString() | It returns a string representation of the integer argument as an unsigned integer in binary base 16. |
33) | static String | toOctalString() | It returns a string representation of the integer argument as an unsigned integer in binary base 8. |
34) | String | toString() | It returns a String object representing the value of the Number Object. |
35) | static String | toUnsignedString() | It converts the argument to a long by an unsigned conversion. |
36) | static long | toUnsignedLong() | It returns a string representation of the argument as an unsigned decimal value. |
37) | static Integer | valueOf() | It returns the relevant Integer Object holding the value of the argument passed. |
Next TopicJava Integer