Class java.lang.Integer
All Packages Class Hierarchy This Package Previous Next Index
Class java.lang.Integer
java.lang.Object
|
+----java.lang.Number
|
+----java.lang.Integer
- public final class Integer
- extends Number
The Integer class is a wrapper for integer values. In Java, integers are not objects and most of the Java utility classes require the use of objects. Thus, if you needed to store an integer in a hashtable, you would have to "wrap" an Integer instance around it.
- MAX_VALUE
- The maximum value an Integer can have.
- MIN_VALUE
- The minimum value an Integer can have.
- Integer(int)
- Constructs an Integer object initialized to the specified int value.
- Integer(String)
- Constructs an Integer object initialized to the value specified by the
String parameter.
- doubleValue()
- Returns the value of this Integer as a double.
- equals(Object)
- Compares this object to the specified object.
- floatValue()
- Returns the value of this Integer as a float.
- getInteger(String)
- Gets an Integer property.
- getInteger(String, int)
- Gets an Integer property.
- getInteger(String, Integer)
- Gets an Integer property.
- hashCode()
- Returns a hashcode for this Integer.
- intValue()
- Returns the value of this Integer as an int.
- longValue()
- Returns the value of this Integer as a long.
- parseInt(String)
- Assuming the specified String represents an integer, returns that integer's
value.
- parseInt(String, int)
- Assuming the specified String represents an integer, returns that integer's
value.
- toBinaryString(int)
- Returns a new String object representing the specified integer as unsigned binary number.
- toHexString(int)
- Returns a new String object representing the specified integer as unsigned hexidecimal number.
- toOctalString(int)
- Returns a new String object representing the specified integer as unsigned octal number.
- toString()
- Returns a String object representing this Integer's value.
- toString(int)
- Returns a new String object representing the specified integer.
- toString(int, int)
- Returns a new String object representing the specified integer in
the specified radix.
- valueOf(String)
- Assuming the specified String represents an integer, returns a new Integer
object initialized to that value.
- valueOf(String, int)
- Assuming the specified String represents an integer, returns a new Integer
object initialized to that value.
MIN_VALUE
public final static int MIN_VALUE
- The minimum value an Integer can have. The lowest minimum value an
Integer can have is 0x80000000.
MAX_VALUE
public final static int MAX_VALUE
- The maximum value an Integer can have. The greatest maximum value an
Integer can have is 0x7fffffff.
Integer
public Integer(int value)
- Constructs an Integer object initialized to the specified int value.
- Parameters:
- value - the initial value of the Integer
Integer
public Integer(String s) throws NumberFormatException
- Constructs an Integer object initialized to the value specified by the
String parameter. The radix is assumed to be 10.
- Parameters:
- s - the String to be converted to an Integer
- Throws: NumberFormatException
- If the String does not contain a parsable integer.
toString
public static String toString(int i,
int radix)
- Returns a new String object representing the specified integer in
the specified radix.
- Parameters:
- i - the integer to be converted
- radix - the radix
- See Also:
- MIN_RADIX, MAX_RADIX
toHexString
public static String toHexString(int i)
- Returns a new String object representing the specified integer as unsigned hexidecimal number.
toOctalString
public static String toOctalString(int i)
- Returns a new String object representing the specified integer as unsigned octal number.
toBinaryString
public static String toBinaryString(int i)
- Returns a new String object representing the specified integer as unsigned binary number.
toString
public static String toString(int i)
- Returns a new String object representing the specified integer. The radix
is assumed to be 10.
- Parameters:
- i - the integer to be converted
parseInt
public static int parseInt(String s,
int radix) throws NumberFormatException
- Assuming the specified String represents an integer, returns that integer's
value. Throws an exception if the String cannot be parsed as an int.
- Parameters:
- s - the String containing the integer
- radix - the radix to be used
- Throws: NumberFormatException
- If the String does not contain a parsable integer.
parseInt
public static int parseInt(String s) throws NumberFormatException
- Assuming the specified String represents an integer, returns that integer's
value. Throws an exception if the String cannot be parsed as an int.
The radix is assumed to be 10.
- Parameters:
- s - the String containing the integer
- Throws: NumberFormatException
- If the string does not contain a parsable integer.
valueOf
public static Integer valueOf(String s,
int radix) throws NumberFormatException
- Assuming the specified String represents an integer, returns a new Integer
object initialized to that value. Throws an exception if the String cannot be
parsed as an int.
- Parameters:
- s - the String containing the integer
- radix - the radix to be used
- Throws: NumberFormatException
- If the String does not contain a parsable integer.
valueOf
public static Integer valueOf(String s) throws NumberFormatException
- Assuming the specified String represents an integer, returns a new Integer
object initialized to that value. Throws an exception if the String cannot be
parsed as an int. The radix is assumed to be 10.
- Parameters:
- s - the String containing the integer
- Throws: NumberFormatException
- If the String does not contain a parsable integer.
intValue
public int intValue()
- Returns the value of this Integer as an int.
- Overrides:
- intValue in class Number
longValue
public long longValue()
- Returns the value of this Integer as a long.
- Overrides:
- longValue in class Number
floatValue
public float floatValue()
- Returns the value of this Integer as a float.
- Overrides:
- floatValue in class Number
doubleValue
public double doubleValue()
- Returns the value of this Integer as a double.
- Overrides:
- doubleValue in class Number
toString
public String toString()
- Returns a String object representing this Integer's value.
- Overrides:
- toString in class Object
hashCode
public int hashCode()
- Returns a hashcode for this Integer.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Compares this object to the specified object.
- Parameters:
- obj - the object to compare with
- Returns:
- true if the objects are the same; false otherwise.
- Overrides:
- equals in class Object
getInteger
public static Integer getInteger(String nm)
- Gets an Integer property. If the property does not
exist, it will return 0.
- Parameters:
- nm - the property name
getInteger
public static Integer getInteger(String nm,
int val)
- Gets an Integer property. If the property does not
exist, it will return val. Deals with hexadecimal
and octal numbers.
- Parameters:
- nm - the String name
- val - the Integer value
getInteger
public static Integer getInteger(String nm,
Integer val)
- Gets an Integer property. If the property does not
exist, it will return val. Deals with hexadecimal
and octal numbers.
- Parameters:
- nm - the property name
- val - the integer value
All Packages Class Hierarchy This Package Previous Next Index