java.lang
public
final
class
java.lang.Integer
Summary
Constants
|
|
|
Value |
|
int |
MAX_VALUE |
Constant for the maximum int value, 231-1. |
2147483647 |
0x7fffffff |
int |
MIN_VALUE |
Constant for the minimum int value, -231. |
-2147483648 |
0x80000000 |
int |
SIZE |
Constant for the number of bits to represent an int in
two's compliment form. |
32 |
0x00000020 |
Class<Integer> |
TYPE |
The java.lang.Class that represents this class. |
|
|
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
int
MAX_VALUE
Constant for the maximum int
value, 231-1.
Constant Value:
2147483647
(0x7fffffff)
public
static
final
int
MIN_VALUE
Constant for the minimum int
value, -231.
Constant Value:
-2147483648
(0x80000000)
public
static
final
int
SIZE
Constant for the number of bits to represent an int
in
two's compliment form.
Constant Value:
32
(0x00000020)
public
static
final
Class<Integer>
TYPE
The java.lang.Class that represents this class.
Public Constructors
public
Integer(int value)
Constructs a new instance of the receiver which represents the int valued
argument.
Parameters
value
| the int to store in the new instance.
|
public
Integer(String string)
Constructs a new instance of this class given a string.
Parameters
string
| a string representation of an int quantity. |
Public Methods
public
static
int
bitCount(int i)
Counts the number of 1 bits in the int
value passed; this
is sometimes referred to as a population count.
Parameters
i
| The int value to process. |
public
byte
byteValue()
Returns the byte value which the receiver represents
Returns
- byte the value of the receiver.
public
int
compareTo(Integer object)
Compares this Integer
to the Integer
passed. If this instance's value is equal to the value of the instance
passed, then 0 is returned. If this instance's value is less than the
value of the instance passed, then a negative value is returned. If this
instance's value is greater than the value of the instance passed, then a
positive value is returned.
Parameters
object
| The instance to compare to. |
public
static
Integer
decode(String string)
Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity. The string may be a hexadecimal ("0x..."), octal ("0..."),
or decimal ("...") representation of an integer
Parameters
string
| a string representation of an int quantity. |
Returns
- Integer the value represented by the argument
public
double
doubleValue()
Returns the double value which the receiver represents
Returns
- double the value of the receiver.
public
boolean
equals(Object o)
Compares the argument to the receiver, and returns true if they represent
the
same object using a class specific comparison.
In this case, the argument must also be an Integer, and the receiver and
argument must represent the same int value.
Parameters
o
| the object to compare with this object |
Returns
true
if the object is the same as this object
false
if it is different from this object
public
float
floatValue()
Returns the float value which the receiver represents
Returns
- float the value of the receiver.
public
static
Integer
getInteger(String string)
Returns an Integer representing the integer value of the property named
by the argument. If the property could not be found, or its value could
not be parsed as an integer, answer null.
Parameters
string
| The name of the desired integer property. |
Returns
- Integer An Integer representing the value of the property.
public
static
Integer
getInteger(String string, int defaultValue)
Returns an Integer representing the integer value of the property named
by the argument. If the property could not be found, or its value could
not be parsed as an integer, answer an Integer representing the second
argument.
Parameters
string
| The name of the desired integer property. |
Returns
- Integer An Integer representing the value of the property.
public
static
Integer
getInteger(String string, Integer defaultValue)
Returns an Integer representing the integer value of the property named
by the argument. If the property could not be found, or its value could
not be parsed as an integer, answer the second argument.
Parameters
string
| The name of the desired integer property. |
Returns
- Integer An Integer representing the value of the property.
public
int
hashCode()
Returns an integer hash code for the receiver. Any two objects which
answer
true
when passed to
equals
must
answer the same value for this method.
public
static
int
highestOneBit(int i)
Determines the highest (leftmost) bit that is 1 and returns the value
that is the bit mask for that bit. This is sometimes referred to as the
Most Significant 1 Bit.
Parameters
i
| The int to interrogate. |
Returns
- The bit mask indicating the highest 1 bit.
public
int
intValue()
Returns the int value which the receiver represents
Returns
- int the value of the receiver.
public
long
longValue()
Returns the long value which the receiver represents
Returns
- long the value of the receiver.
public
static
int
lowestOneBit(int i)
Determines the lowest (rightmost) bit that is 1 and returns the value
that is the bit mask for that bit. This is sometimes referred to as the
Least Significant 1 Bit.
Parameters
i
| The int to interrogate. |
Returns
- The bit mask indicating the lowest 1 bit.
public
static
int
numberOfLeadingZeros(int i)
Determines the number of leading zeros in the int
passed
prior to the highest one bit.
Returns
- The number of leading zeros.
public
static
int
numberOfTrailingZeros(int i)
Determines the number of trailing zeros in the int
passed
after the lowest one bit.
Returns
- The number of trailing zeros.
public
static
int
parseInt(String string)
Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity.
Parameters
string
| a string representation of an int quantity. |
Returns
- int the value represented by the argument
public
static
int
parseInt(String string, int radix)
Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity. The second argument specifies the radix to use when parsing
the value.
Parameters
string
| a string representation of an int quantity. |
radix
| the base to use for conversion. |
Returns
- int the value represented by the argument
public
static
int
reverse(int i)
Reverses the bytes of a int
.
public
static
int
reverseBytes(int i)
Reverses the bytes of a int
.
public
static
int
rotateLeft(int i, int distance)
Rotates the bits of i
to the left by the
distance
bits.
Parameters
i
| The int value to rotate left. |
distance
| The number of bits to rotate. |
public
static
int
rotateRight(int i, int distance)
Rotates the bits of i
to the right by the
distance
bits.
Parameters
i
| The int value to rotate right. |
distance
| The number of bits to rotate. |
public
short
shortValue()
Returns the short value which the receiver represents
Returns
- short the value of the receiver.
public
static
int
signum(int i)
The signum
function for int
values. This
method returns -1 for negative values, 1 for positive values and 0 for
the value 0.
Returns
- -1 if negative, 1 if positive otherwise 0.
public
static
String
toBinaryString(int i)
Returns a string containing '0' and '1' characters which describe the
binary representation of the argument.
Parameters
i
| an int to get the binary representation of |
Returns
- String the binary representation of the argument
public
static
String
toHexString(int i)
Returns a string containing characters in the range 0..9, a..f which
describe the hexadecimal representation of the argument.
Parameters
i
| an int to get the hex representation of |
Returns
- String the hex representation of the argument
public
static
String
toOctalString(int i)
Returns a string containing characters in the range 0..7 which describe
the octal representation of the argument.
Parameters
i
| an int to get the octal representation of |
Returns
- String the hex representation of the argument
public
static
String
toString(int i, int radix)
Returns a string containing characters in the range 0..9, a..z (depending
on the radix) which describe the representation of the argument in that
radix.
Parameters
i
| an int to get the representation of |
radix
| the base to use for conversion. |
Returns
- String the representation of the argument
public
String
toString()
Returns a string containing a concise, human-readable description of the
receiver.
Returns
- a printable representation for the receiver.
public
static
String
toString(int i)
Returns a string containing characters in the range 0..9 which describe
the decimal representation of the argument.
Parameters
i
| an int to get the representation of |
Returns
- String the representation of the argument
public
static
Integer
valueOf(String string, int radix)
Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity. The second argument specifies the radix to use when parsing
the value.
Parameters
string
| a string representation of an int quantity. |
radix
| the base to use for conversion. |
Returns
- Integer the value represented by the argument
public
static
Integer
valueOf(String string)
Parses the string argument as if it was an int value and returns the
result. Throws NumberFormatException if the string does not represent an
int quantity.
Parameters
string
| a string representation of an int quantity. |
Returns
- Integer the value represented by the argument
public
static
Integer
valueOf(int i)
Returns a Integer
instance for the int
value passed. This method is preferred over the constructor, as this
method may maintain a cache of instances.