Integer
class wraps a value of the primitive type
int
in an object. An object of type Integer
contains a single field whose type is int
.
In addition, this class provides several methods for converting
an int
to a String
and a String
to an
int
, as well as other constants and methods useful when
dealing with an int
.
This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail.
Implementation Note
The implementations of the "bit twiddling"
methods (such as highestOneBit
and
numberOfTrailingZeros
) are
based on material from Henry S. Warren, Jr.'s Hacker's
Delight, (Addison Wesley, 2002).
Modifier and Type | Class and Description |
---|---|
private static class | Integer.
Cache to support the object identity semantics of autoboxing for values between -128 and 127 (inclusive) as required by JLS. |
Modifier and Type | Field and Description |
---|---|
public static final int | BYTES
The number of bytes used to represent an |
pack-priv static final char[] | digits
All possible chars for representing a number as a String |
public static final int | MAX_VALUE
A constant holding the maximum value an |
public static final int | MIN_VALUE
A constant holding the minimum value an |
private static final long | serialVersionUID
use serialVersionUID from JDK 1.0.2 for interoperability
|
public static final int | SIZE
The number of bits used to represent an |
public static final Class | TYPE
The |
private final int | value
The value of the |
Access | Constructor and Description |
---|---|
public | Integer(int
the value to be represented by the
value)Integer object.
Deprecated
for removal since 9. It is rarely appropriate to use this constructor.
Constructs a newly allocated |
public |
Modifier and Type | Method and Description |
---|---|
public static int | Returns: the number of one-bits in the two's complement binary representation of the specifiedint value.the value whose bits are to be counted i)Returns the number of one-bits in the two's complement binary
representation of the specified |
public byte | byteValue()
Overrides java. Returns the value of this |
public static int | Returns: the value0 if x == y ;
a value less than 0 if x < y ; and
a value greater than 0 if x > y the first x, int int to comparethe second y)int to compareCompares two |
public int | Returns: the value0 if this Integer is
equal to the argument Integer ; a value less than
0 if this Integer is numerically less
than the argument Integer ; and a value greater
than 0 if this Integer is numerically
greater than the argument Integer (signed
comparison).the anotherInteger)Integer to be compared.Implements java. Compares two |
public static int | Returns: the value0 if x == y ; a value less
than 0 if x < y as unsigned values; and
a value greater than 0 if x > y as
unsigned valuesthe first x, int int to comparethe second y)int to compareCompares two |
public static int | Returns: the compressed valuethe value whose bits are to be compressed i, int the bit mask mask)Returns the value obtained by compressing the bits of the
specified |
public static Integer | |
public Optional | describeConstable()
Implements java. Returns an |
public static int | Returns: the unsigned quotient of the first argument divided by the second argumentthe value to be divided dividend, int the value doing the dividing divisor)Returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value. |
public double | doubleValue()
Implements abstract java. Returns the value of this |
public boolean | Returns: true if the objects are the same;
false otherwise.the object to compare with. obj)Overrides java. Compares this object to the specified object. |
public static int | Returns: the expanded valuethe value whose bits are to be expanded i, int the bit mask mask)Returns the value obtained by expanding the bits of the
specified |
public float | floatValue()
Implements abstract java. Returns the value of this |
private static void | formatUnsignedInt(int
the unsigned int to format val, int the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) shift, byte[] the byte buffer to write to buf, int the number of characters to write len)Format an |
private static void | formatUnsignedIntUTF16(int
the unsigned int to format val, int the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) shift, byte[] the byte buffer to write to buf, int the number of characters to write len)Format an |
public static Integer | Returns: theInteger value of the property.property name. nm)Determines the integer value of the system property with the specified name. |
public static Integer | Returns: theInteger value of the property.property name. nm, int default value. val)Determines the integer value of the system property with the specified name. |
public static Integer | Returns: theInteger value of the property.property name. nm, Integer default value. val)Returns the integer value of the system property with the specified name. |
public int | Returns: a hash code value for this object, equal to the primitiveint value represented by this
Integer object.Overrides java. Returns a hash code for this |
public static int | Returns: a hash code value for anint value.the value to hash value)Returns a hash code for an |
public static int | Returns: anint value with a single one-bit, in the position
of the highest-order one-bit in the specified value, or zero if
the specified value is itself equal to zero.the value whose highest one bit is to be computed i)Returns an |
public int | intValue()
Implements abstract java. Returns the value of this |
public long | longValue()
Implements abstract java. Returns the value of this |
public static int | Returns: anint value with a single one-bit, in the position
of the lowest-order one-bit in the specified value, or zero if
the specified value is itself equal to zero.the value whose lowest one bit is to be computed i)Returns an |
public static int | |
public static int | |
public static int | Returns: the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specifiedint value, or 32 if the value
is equal to zero.the value whose number of leading zeros is to be computed i)Returns the number of zero bits preceding the highest-order
("leftmost") one-bit in the two's complement binary representation
of the specified |
public static int | Returns: the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specifiedint value, or 32 if the value is equal
to zero.the value whose number of trailing zeros is to be computed i)Returns the number of zero bits following the lowest-order ("rightmost")
one-bit in the two's complement binary representation of the specified
|
private static int | |
public static int | |
public static int | Returns: the signedint represented by the subsequence in
the specified radix.the s, int CharSequence containing the int
representation to be parsedthe beginning index, inclusive. beginIndex, int the ending index, exclusive. endIndex, int the radix to be used while parsing radix)s .Parses the |
public static int | |
public static int | Returns: the integer represented by the string argument in the specified radix.the s, int String containing the unsigned integer
representation to be parsedthe radix to be used while parsing radix)s .Parses the string argument as an unsigned integer in the radix specified by the second argument. |
public static int | Returns: the unsignedint represented by the subsequence in
the specified radix.the s, int CharSequence containing the unsigned
int representation to be parsedthe beginning index, inclusive. beginIndex, int the ending index, exclusive. endIndex, int the radix to be used while parsing radix)s .Parses the |
public static int | Returns: the unsigned integer value represented by the argument in decimal.a s)String containing the unsigned int
representation to be parsedParses the string argument as an unsigned decimal integer. |
public static int | Returns: the unsigned remainder of the first argument divided by the second argumentthe value to be divided dividend, int the value doing the dividing divisor)Returns the unsigned remainder from dividing the first argument by the second where each argument and the result is interpreted as an unsigned value. |
public Integer | Returns: the Integer instanceignored lookupImplements java. Resolves this instance as a |
public static int | Returns: the value obtained by reversing order of the bits in the specifiedint value.the value to be reversed i)Returns the value obtained by reversing the order of the bits in the
two's complement binary representation of the specified |
public static int | Returns: the value obtained by reversing the bytes in the specifiedint value.the value whose bytes are to be reversed i)Returns the value obtained by reversing the order of the bytes in the
two's complement representation of the specified |
public static int | Returns: the value obtained by rotating the two's complement binary representation of the specifiedint value left by the
specified number of bits.the value whose bits are to be rotated left i, int the number of bit positions to rotate left distance)Returns the value obtained by rotating the two's complement binary
representation of the specified |
public static int | Returns: the value obtained by rotating the two's complement binary representation of the specifiedint value right by the
specified number of bits.the value whose bits are to be rotated right i, int the number of bit positions to rotate right distance)Returns the value obtained by rotating the two's complement binary
representation of the specified |
public short | shortValue()
Overrides java. Returns the value of this |
public static int | Returns: the signum function of the specifiedint value.the value whose signum is to be computed i)Returns the signum function of the specified |
pack-priv static int | Returns: string sizeint value x)Returns the string representation size for a given int value. |
public static int | Returns: the sum ofa and b the first operand a, int the second operand b)Adds two integers together as per the + operator. |
public static String | Returns: the string representation of the unsigned integer value represented by the argument in binary (base 2).an integer to be converted to a string. i)Returns a string representation of the integer argument as an unsigned integer in base 2. |
public static String | Returns: the string representation of the unsigned integer value represented by the argument in hexadecimal (base 16).an integer to be converted to a string. i)Returns a string representation of the integer argument as an unsigned integer in base 16. |
public static String | Returns: the string representation of the unsigned integer value represented by the argument in octal (base 8).an integer to be converted to a string. i)Returns a string representation of the integer argument as an unsigned integer in base 8. |
public static String | Returns: a string representation of the argument in the specified radix.an integer to be converted to a string. i, int the radix to use in the string representation. radix)Returns a string representation of the first argument in the radix specified by the second argument. |
public static String | Returns: a string representation of the argument in base 10.an integer to be converted. i)Returns a |
public String | Returns: a string representation of the value of this object in base 10.Overrides java. Returns a |
private static String | |
public static long | Returns: the argument converted tolong by an unsigned
conversionthe value to convert to an unsigned x)long Converts the argument to a |
public static String | Returns: an unsigned string representation of the argument in the specified radix.an integer to be converted to an unsigned string. i, int the radix to use in the string representation. radix)Returns a string representation of the first argument as an unsigned integer value in the radix specified by the second argument. |
public static String | Returns: an unsigned string representation of the argument.an integer to be converted to an unsigned string. i)Returns a string representation of the argument as an unsigned decimal value. |
private static String | |
public static Integer | Returns: anInteger object holding the value
represented by the string argument in the specified
radix.the string to be parsed. s, int the radix to be used in interpreting radix)s Returns an |
public static Integer | |
public static Integer | Returns: anInteger instance representing i .an i)int value.Returns an |