java.lang
Class Integer

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Integer
All Implemented Interfaces:
Comparable<Integer>

public final class Integer
extends Number
implements Comparable<Integer>

Minimal Integer implementation that supports converting an int to a String.

Author:
others, Sven Köhler

Field Summary
static int MAX_RADIX
          Deprecated. use constant in Character
static int MAX_VALUE
          The largest value of type int.
static int MIN_RADIX
          Deprecated. use constant in Character
static int MIN_VALUE
          The smallest value of type int.
static int SIZE
           
 
Constructor Summary
Integer(int value)
          Constructs a newly allocated Integer object that represents the primitive int argument.
Integer(String s)
           
 
Method Summary
 int bitCount(int v)
           
 byte byteValue()
          Return the byte value of this Number.
 int compareTo(Integer ob)
          Compares this with another Object.
static int digit(char ch, int radix)
          Deprecated. use Character.digit(char, int) instead.
static int digit(int ch, int radix)
          Deprecated. use Character.digit(int, int) instead.
 double doubleValue()
          Return the double value of this Number.
 boolean equals(Object o)
           
 float floatValue()
          Return the float value of this Number.
 int hashCode()
           
static int highestOneBit(int v)
           
 int intValue()
          returns the value of this Integer as int
 long longValue()
          Return the long value of this Number.
static int lowestOneBit(int v)
           
static int numberOfLeadingZeros(int v)
           
static int numberOfTrailingZeros(int v)
           
static int parseInt(String s)
           
static int parseInt(String s, int radix)
          This method parses an int from a String.
static int reverse(int v)
           
static int reverseBytes(int v)
           
static int rotateLeft(int v, int bits)
           
static int rotateRight(int v, int bits)
           
 short shortValue()
          Return the short value of this Number.
static int signnum(long i)
           
static String toBinaryString(int v)
           
static String toHexString(int v)
          Return the hex representation of an int as a String
static String toOctalString(int v)
           
 String toString()
          Returns a String object representing this Integer's value.
static String toString(int v)
          Returns a new String object representing the specified integer.
static String toString(int v, int radix)
           
static Integer valueOf(int v)
           
static Integer valueOf(String s)
           
static Integer valueOf(String s, int radix)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_VALUE

public static final int MAX_VALUE
The largest value of type int. The constant value of this field is 2147483647.

See Also:
Constant Field Values

MIN_VALUE

public static final int MIN_VALUE
The smallest value of type int. The constant value of this field is -2147483648.

See Also:
Constant Field Values

SIZE

public static final int SIZE
See Also:
Constant Field Values

MIN_RADIX

@Deprecated
public static final int MIN_RADIX
Deprecated. use constant in Character
See Also:
Constant Field Values

MAX_RADIX

@Deprecated
public static final int MAX_RADIX
Deprecated. use constant in Character
See Also:
Constant Field Values
Constructor Detail

Integer

public Integer(int value)
Constructs a newly allocated Integer object that represents the primitive int argument.

Parameters:
value - the value to be represented by the Integer.

Integer

public Integer(String s)
Method Detail

bitCount

public int bitCount(int v)

byteValue

public byte byteValue()
Description copied from class: Number
Return the byte value of this Number.

Overrides:
byteValue in class Number
Returns:
the byte value

compareTo

public int compareTo(Integer ob)
Description copied from interface: Comparable
Compares this with another Object. Returns -1 if this object is smaller, 0 if both objects are equal and 1 if this object is bigger.

Specified by:
compareTo in interface Comparable<Integer>
Parameters:
ob - the object to compare with
Returns:
one of the values -1, 0, 1

doubleValue

public double doubleValue()
Description copied from class: Number
Return the double value of this Number.

Specified by:
doubleValue in class Number
Returns:
the double value

equals

public boolean equals(Object o)
Overrides:
equals in class Object

floatValue

public float floatValue()
Description copied from class: Number
Return the float value of this Number.

Specified by:
floatValue in class Number
Returns:
the float value

hashCode

public int hashCode()
Overrides:
hashCode in class Object

highestOneBit

public static int highestOneBit(int v)

intValue

public int intValue()
returns the value of this Integer as int

Specified by:
intValue in class Number
Returns:
the int value represented by this object.

longValue

public long longValue()
Description copied from class: Number
Return the long value of this Number.

Specified by:
longValue in class Number
Returns:
the long value

lowestOneBit

public static int lowestOneBit(int v)

numberOfLeadingZeros

public static int numberOfLeadingZeros(int v)

numberOfTrailingZeros

public static int numberOfTrailingZeros(int v)

parseInt

public static int parseInt(String s)

parseInt

public static int parseInt(String s,
                           int radix)
This method parses an int from a String. The string can contain letters if the number system is larger than decimal, such as hexidecimal numbers.

Parameters:
s - The number string e.g. "123" or "FF" if radix is 16.
radix - The base number system e.g. 16
Returns:
the integer value
Throws:
NumberFormatException

reverse

public static int reverse(int v)

reverseBytes

public static int reverseBytes(int v)

rotateLeft

public static int rotateLeft(int v,
                             int bits)

rotateRight

public static int rotateRight(int v,
                              int bits)

shortValue

public short shortValue()
Description copied from class: Number
Return the short value of this Number.

Overrides:
shortValue in class Number
Returns:
the short value

signnum

public static int signnum(long i)

toBinaryString

public static String toBinaryString(int v)

toHexString

public static String toHexString(int v)
Return the hex representation of an int as a String

Parameters:
v - the int
Returns:
the hex string

toOctalString

public static String toOctalString(int v)

toString

public String toString()
Returns a String object representing this Integer's value. The value is converted to signed decimal representation and returned as a string.

Overrides:
toString in class Object
Returns:
a string representation of the value of this object in base 10.

toString

public static String toString(int v)
Returns a new String object representing the specified integer. The argument is converted to signed decimal representation and returned as a string, exactly as if the argument and radix 10 were given as arguments to the toString(int, int) method.

Parameters:
v - an integer to be converted.
Returns:
a string representation of the argument in base 10.

toString

public static String toString(int v,
                              int radix)

valueOf

public static Integer valueOf(int v)

valueOf

public static Integer valueOf(String s)

valueOf

public static Integer valueOf(String s,
                              int radix)

digit

@Deprecated
public static int digit(char ch,
                                   int radix)
Deprecated. use Character.digit(char, int) instead.


digit

@Deprecated
public static int digit(int ch,
                                   int radix)
Deprecated. use Character.digit(int, int) instead.