This class provides an immutable object
wrapper around the int
primitive data type. This class also contains useful minimum and
maximum constants and useful
conversion methods.
parseInt( ) and
valueOf( ) convert a string to an
int or to an Integer,
respectively. Each can take a radix argument to specify the base the
value is represented in. decode(
) also converts a
String to an Integer. It
assumes a hexadecimal number if the string
begins with "0X" or
"0x", or an octal number if the
string begins with "0". Otherwise,
a decimal number is assumed. toString(
) converts
in the other direction, and the static version
takes a radix argument. toBinaryString(
)
,
toOctalString( ), and toHexString(
) convert an int to a string using base
2, base 8, and base 16. These methods treat the integer as an
unsigned value. Other routines return the value of an
Integer as various primitive types, and, finally,
the getInteger( ) methods return the integer value of a
named property from the system property list, or the specified
default value.
Java 5.0 adds a number of static methods
that operate on the bits of an int value.
rotateLeft( ) and rotateRight( )
shift the bits the specified distance in the specified direction,
with bits shifted off one end being shifted in on the other end.
signum( ) returns
the sign of the integer as -1, 0, or 1. highestOneBit(
)
, numberOfTrailingZeros(
), bitCount( ) and related methods can
be useful if you use an int value as a set of bits
and want to iterate through the ones bits in the set.
public final class Integer extends Number implements Comparable<Integer> {
// Public Constructors
public Integer(int value);
public Integer(String s) throws NumberFormatException;
// Public Constants
public static final int MAX_VALUE; =2147483647
public static final int MIN_VALUE; =-2147483648
5.0 public static final int SIZE; =32
1.1 public static final Class<Integer> TYPE;
// Public Class Methods
5.0 public static int bitCount(int i);
1.1 public static Integer decode(String nm) throws NumberFormatException;
public static Integer getInteger(String nm);
public static Integer getInteger(String nm, int val);
public static Integer getInteger(String nm, Integer val);
5.0 public static int highestOneBit(int i);
5.0 public static int lowestOneBit(int i);
5.0 public static int numberOfLeadingZeros(int i);
5.0 public static int numberOfTrailingZeros(int i);
public static int parseInt(String s) throws NumberFormatException;
public static int parseInt(String s, int radix) throws NumberFormatException;
5.0 public static int reverse(int i);
5.0 public static int reverseBytes(int i);
5.0 public static int rotateLeft(int i, int distance);
5.0 public static int rotateRight(int i, int distance);
5.0 public static int signum(int i);
public static String toBinaryString(int i);
public static String toHexString(int i);
public static String toOctalString(int i);
public static String toString(int i);
public static String toString(int i, int radix);
5.0 public static Integer valueOf(int i);
public static Integer valueOf(String s) throws NumberFormatException;
public static Integer valueOf(String s, int radix) throws NumberFormatException;
// Methods Implementing Comparable
1.2 public int compareTo(Integer anotherInteger);
// Public Methods Overriding Number
1.1 public byte byteValue( );
public double doubleValue( );
public float floatValue( );
public int intValue( );
public long longValue( );
1.1 public short shortValue( );
// Public Methods Overriding Object
public boolean equals(Object obj);
public int hashCode( );
public String toString( );
}