java.lang
Class Integer
- java.lang.Object
-
- java.lang.Number
-
- java.lang.Integer
-
- All Implemented Interfaces:
- Serializable, Comparable<Integer>
public final class Integer extends Number implements Comparable<Integer>
TheInteger
class wraps a value of the primitive typeint
in an object. An object of typeInteger
contains a single field whose type isint
.In addition, this class provides several methods for converting an
int
to aString
and aString
to anint
, as well as other constants and methods useful when dealing with anint
.Implementation note: The implementations of the "bit twiddling" methods (such as
highestOneBit
andnumberOfTrailingZeros
) are based on material from Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002).- Since:
- JDK1.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static int
MAX_VALUE
A constant holding the maximum value anint
can have, 231-1.static int
MIN_VALUE
A constant holding the minimum value anint
can have, -231.static int
SIZE
The number of bits used to represent anint
value in two's complement binary form.static Class<Integer>
TYPE
TheClass
instance representing the primitive typeint
.
-
Constructor Summary
Constructors Constructor and Description Integer(int value)
Constructs a newly allocatedInteger
object that represents the specifiedint
value.Integer(String s)
Constructs a newly allocatedInteger
object that represents theint
value indicated by theString
parameter.
-
Method Summary
Methods Modifier and Type Method and Description static int
bitCount(int i)
Returns the number of one-bits in the two's complement binary representation of the specifiedint
value.byte
byteValue()
Returns the value of thisInteger
as abyte
.static int
compare(int x, int y)
Compares twoint
values numerically.int
compareTo(Integer anotherInteger)
Compares twoInteger
objects numerically.static Integer
decode(String nm)
Decodes aString
into anInteger
.double
doubleValue()
Returns the value of thisInteger
as adouble
.boolean
equals(Object obj)
Compares this object to the specified object.float
floatValue()
Returns the value of thisInteger
as afloat
.static Integer
getInteger(String nm)
Determines the integer value of the system property with the specified name.static Integer
getInteger(String nm, int val)
Determines the integer value of the system property with the specified name.static Integer
getInteger(String nm, Integer val)
Returns the integer value of the system property with the specified name.int
hashCode()
Returns a hash code for thisInteger
.static int
highestOneBit(int i)
Returns anint
value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specifiedint
value.int
intValue()
Returns the value of thisInteger
as anint
.long
longValue()
Returns the value of thisInteger
as along
.static int
lowestOneBit(int i)
Returns anint
value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specifiedint
value.static int
numberOfLeadingZeros(int i)
Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specifiedint
value.static int
numberOfTrailingZeros(int i)
Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specifiedint
value.static int
parseInt(String s)
Parses the string argument as a signed decimal integer.static int
parseInt(String s, int radix)
Parses the string argument as a signed integer in the radix specified by the second argument.static int
reverse(int i)
Returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specifiedint
value.static int
reverseBytes(int i)
Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specifiedint
value.static int
rotateLeft(int i, int distance)
Returns the value obtained by rotating the two's complement binary representation of the specifiedint
value left by the specified number of bits.static int
rotateRight(int i, int distance)
Returns the value obtained by rotating the two's complement binary representation of the specifiedint
value right by the specified number of bits.short
shortValue()
Returns the value of thisInteger
as ashort
.static int
signum(int i)
Returns the signum function of the specifiedint
value.static String
toBinaryString(int i)
Returns a string representation of the integer argument as an unsigned integer in base 2.static String
toHexString(int i)
Returns a string representation of the integer argument as an unsigned integer in base 16.static String
toOctalString(int i)
Returns a string representation of the integer argument as an unsigned integer in base 8.String
toString()
Returns aString
object representing thisInteger
's value.static String
toString(int i)
Returns aString
object representing the specified integer.static String
toString(int i, int radix)
Returns a string representation of the first argument in the radix specified by the second argument.static Integer
valueOf(int i)
Returns anInteger
instance representing the specifiedint
value.static Integer
valueOf(String s)
Returns anInteger
object holding the value of the specifiedString
.static Integer
valueOf(String s, int radix)
Returns anInteger
object holding the value extracted from the specifiedString
when parsed with the radix given by the second argument.
-
'Dev. 자바 > API 및 이론' 카테고리의 다른 글
[JAVA API] java.util.Random (0) | 2012.08.03 |
---|---|
[API] java.util.Calendar (0) | 2012.08.03 |
[API] java.lang.String (0) | 2012.08.03 |
[API] java.lang.Object (0) | 2012.08.03 |
자바 메모리 영역의 사용 (0) | 2012.07.26 |