java.lang
Class Integer

java.lang.Object
  extended by java.lang.Integer

public final class Integer
extends Object

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


Field Summary
static int MAX_RADIX
          Normally this is stored in Character in the standard java.lang package but we don't have Character.
static int MAX_VALUE
          The largest value of type int.
static int MIN_RADIX
          Normally this is stored in Character in the standard java.lang package but we don't have Character.
static int MIN_VALUE
          The smallest value of type int.
 
Constructor Summary
Integer(int value)
          Constructs a newly allocated Integer object that represents the primitive int argument.
 
Method Summary
static int digit(char ch, int radix)
          This method accepts a character such as '7' or 'C' and converts it to a number value.
static int digit(int codePoint, int radix)
           
static int parseInt(String s)
           
static int parseInt(String s, int radix)
          This method parses an int from a String.
 String toString()
          Returns a String object representing this Integer's value.
static String toString(int i)
          Returns a new String object representing the specified integer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait
 

Field Detail

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

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_RADIX

public static final int MIN_RADIX
Normally this is stored in Character in the standard java.lang package but we don't have Character.

See Also:
Constant Field Values

MAX_RADIX

public static final int MAX_RADIX
Normally this is stored in Character in the standard java.lang package but we don't have 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.
Method Detail

parseInt

public static int parseInt(String s,
                           int radix)
                    throws NumberFormatException
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

parseInt

public static int parseInt(String s)
                    throws NumberFormatException
Throws:
NumberFormatException

digit

public static int digit(char ch,
                        int radix)
This method accepts a character such as '7' or 'C' and converts it to a number value. So '7' returns 7 and 'C' returns 12, which is the hexidecimal value of C. You must specify a radix for the number system, and if your character is outside the bounds it throws a NumberFormatException. e.g. 'G' with radix of 16 will throw the exception. Normally this method is in Character but we don't have that class. If we ever make one we can move this method to it.

Parameters:
ch -
radix -
Returns:
the digit

digit

public static int digit(int codePoint,
                        int radix)

toString

public static String toString(int i)
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:
i - an integer to be converted.
Returns:
a string representation of the argument in base 10.

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.