|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
java.lang.Integer
public final class Integer
Integer is the wrapper for the primitive type int.
As with the specification, this implementation relied on code laid out in Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002) as well as The Aggregate's Magic Algorithms.
Number,
Serialized Form| Nested Class Summary | |
|---|---|
(package private) static class |
Integer.valueOfCache
|
| Field Summary | |
|---|---|
static int |
MAX_VALUE
Constant for the maximum int value, 231-1. |
static int |
MIN_VALUE
Constant for the minimum int value, -231. |
static int |
SIZE
Constant for the number of bits to represent an int in
two's compliment form. |
static Class<Integer> |
TYPE
The java.lang.Class that represents this class. |
| Constructor Summary | |
|---|---|
Integer(int value)
Constructs a new instance of the receiver which represents the int valued argument. |
|
Integer(String string)
Constructs a new instance of this class given a string. |
|
| Method Summary | |
|---|---|
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. |
byte |
byteValue()
Returns the byte value which the receiver represents |
int |
compareTo(Integer object)
Compares this Integer to the Integer
passed. |
static Integer |
decode(String string)
Parses the string argument as if it was an int value and returns the result. |
double |
doubleValue()
Returns the double value which the receiver represents |
boolean |
equals(Object o)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. |
float |
floatValue()
Returns the float value which the receiver represents |
static Integer |
getInteger(String string)
Returns an Integer representing the integer value of the property named by the argument. |
static Integer |
getInteger(String string,
int defaultValue)
Returns an Integer representing the integer value of the property named by the argument. |
static Integer |
getInteger(String string,
Integer defaultValue)
Returns an Integer representing the integer value of the property named by the argument. |
int |
hashCode()
Returns an integer hash code for the receiver. |
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. |
int |
intValue()
Returns the int value which the receiver represents |
long |
longValue()
Returns the long value which the receiver represents |
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. |
static int |
numberOfLeadingZeros(int i)
Determines the number of leading zeros in the int passed
prior to the highest one bit. |
static int |
numberOfTrailingZeros(int i)
Determines the number of trailing zeros in the int passed
after the lowest one bit. |
static int |
parseInt(String string)
Parses the string argument as if it was an int value and returns the result. |
static int |
parseInt(String string,
int radix)
Parses the string argument as if it was an int value and returns the result. |
static int |
reverse(int i)
Reverses the bytes of a int. |
static int |
reverseBytes(int i)
Reverses the bytes of a int. |
static int |
rotateLeft(int i,
int distance)
Rotates the bits of i to the left by the
distance bits. |
static int |
rotateRight(int i,
int distance)
Rotates the bits of i to the right by the
distance bits. |
short |
shortValue()
Returns the short value which the receiver represents |
static int |
signum(int i)
The signum function for int values. |
static String |
toBinaryString(int i)
Returns a string containing '0' and '1' characters which describe the binary representation of the argument. |
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. |
static String |
toOctalString(int i)
Returns a string containing characters in the range 0..7 which describe the octal representation of the argument. |
String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
static String |
toString(int i)
Returns a string containing characters in the range 0..9 which describe the decimal representation of the argument. |
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. |
static Integer |
valueOf(int i)
Returns a Integer instance for the int
value passed. |
static Integer |
valueOf(String string)
Parses the string argument as if it was an int value and returns the result. |
static Integer |
valueOf(String string,
int radix)
Parses the string argument as if it was an int value and returns the result. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_VALUE
Constant for the maximum int value, 231-1.
public static final int MIN_VALUE
Constant for the minimum int value, -231.
public static final int SIZE
Constant for the number of bits to represent an int in
two's compliment form.
public static final Class<Integer> TYPE
| Constructor Detail |
|---|
public Integer(int value)
value - the int to store in the new instance.
public Integer(String string)
throws NumberFormatException
string - a string representation of an int quantity.
NumberFormatException - if the argument could not be parsed as an int quantity.| Method Detail |
|---|
public byte byteValue()
byteValue in class Numberpublic 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.
compareTo in interface Comparable<Integer>object - The instance to compare to.
NullPointerException - if object is null.
public static Integer decode(String string)
throws NumberFormatException
string - a string representation of an int quantity.
NumberFormatException - if the argument could not be parsed as an int quantity.public double doubleValue()
doubleValue in class Numberpublic boolean equals(Object o)
In this case, the argument must also be an Integer, and the receiver and argument must represent the same int value.
equals in class Objecto - the object to compare with this object
true if the object is the same as this object
false if it is different from this objecthashCode()public float floatValue()
floatValue in class Numberpublic static Integer getInteger(String string)
string - The name of the desired integer property.
public static Integer getInteger(String string,
int defaultValue)
string - The name of the desired integer property.
public static Integer getInteger(String string,
Integer defaultValue)
string - The name of the desired integer property.
public int hashCode()
true when passed to equals must
answer the same value for this method.
hashCode in class Objectequals(java.lang.Object)public int intValue()
intValue in class Numberpublic long longValue()
longValue in class Number
public static int parseInt(String string)
throws NumberFormatException
string - a string representation of an int quantity.
NumberFormatException - if the argument could not be parsed as an int quantity.
public static int parseInt(String string,
int radix)
throws NumberFormatException
string - a string representation of an int quantity.radix - the base to use for conversion.
NumberFormatException - if the argument could not be parsed as an int quantity.public short shortValue()
shortValue in class Numberpublic static String toBinaryString(int i)
i - an int to get the binary representation of
public static String toHexString(int i)
i - an int to get the hex representation of
public static String toOctalString(int i)
i - an int to get the octal representation of
public String toString()
toString in class Objectpublic static String toString(int i)
i - an int to get the representation of
public static String toString(int i,
int radix)
i - an int to get the representation ofradix - the base to use for conversion.
public static Integer valueOf(String string)
throws NumberFormatException
string - a string representation of an int quantity.
NumberFormatException - if the argument could not be parsed as an int quantity.
public static Integer valueOf(String string,
int radix)
throws NumberFormatException
string - a string representation of an int quantity.radix - the base to use for conversion.
NumberFormatException - if the argument could not be parsed as an int quantity.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.
i - The int to interrogate.
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.
i - The int to interrogate.
public static int numberOfLeadingZeros(int i)
Determines the number of leading zeros in the int passed
prior to the highest one bit.
i - The int to process.
public static int numberOfTrailingZeros(int i)
Determines the number of trailing zeros in the int passed
after the lowest one bit.
i - The int to process.
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.
i - The int value to process.
public static int rotateLeft(int i,
int distance)
Rotates the bits of i to the left by the
distance bits.
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.
i - The int value to rotate right.distance - The number of bits to rotate.
public static int reverseBytes(int i)
Reverses the bytes of a int.
i - The int to reverse.
public static int reverse(int i)
Reverses the bytes of a int.
i - The int to reverse.
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.
i - The int value.
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.
i - The int value.
Integer instance.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||