java.lang
Class Long

java.lang.Object
  |
  +--java.lang.Number
        |
        +--java.lang.Long

public final class Long
extends Number

The Long class provides an object wrapper for Long data values and serves as a place for long-oriented operations. A wrapper is useful because most of Java's utility classes require the use of objects. Since longs are not objects in Java, they need to be "wrapped" in a Long instance.


Field Summary
static long MAX_VALUE
          The maximum value a Long can have.
static long MIN_VALUE
          The minimum value a Long can have.
 
Constructor Summary
Long(long value)
          Constructs a Long object initialized to the specified value.
Long(String s)
          Constructs a Long object initialized to the value specified by the String parameter.
 
Method Summary
 double doubleValue()
          Returns the value of this Long as a double.
 boolean equals(Object obj)
          Compares this object against the specified object.
 float floatValue()
          Returns the value of this Long as a float.
static Long getLong(String nm)
          Gets a Long property.
static Long getLong(String nm, long val)
          Gets a Long property.
static Long getLong(String nm, Long val)
          Gets a Long property.
 int hashCode()
          Computes a hashcode for this Long.
 int intValue()
          Returns the value of this Long as an int.
 long longValue()
          Returns the value of this Long as a long.
static long parseLong(String s)
          Assuming the specified String represents a long, return that long's value.
static long parseLong(String s, int radix)
          Assuming the specified String represents a long, returns that long's value.
static String toBinaryString(long i)
          Returns a new String object representing the specified long as unsigned octal number.
static String toHexString(long i)
          Returns a new String object representing the specified long as unsigned hexidecimal number.
static String toOctalString(long i)
          Returns a new String object representing the specified long as unsigned octal number.
 String toString()
          Returns a String object representing this Long's value.
static String toString(long i)
          Returns a new String object representing the specified integer.
static String toString(long i, int radix)
          Returns a new String object representing the specified long in the specified radix.
static Long valueOf(String s)
          Assuming the specified String represents a long, returns a new Long object initialized to that value.
static Long valueOf(String s, int radix)
          Assuming the specified String represents a long, returns a new Long object initialized to that value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final long MIN_VALUE
The minimum value a Long can have. The lowest minimum value that a Long can have is 0x8000000000000000.

See Also:
Constant Field Values

MAX_VALUE

public static final long MAX_VALUE
The maximum value a Long can have. The larget maximum value that a Long can have is 0x7fffffffffffffff.

See Also:
Constant Field Values
Constructor Detail

Long

public Long(long value)
Constructs a Long object initialized to the specified value.

Parameters:
value - the initial value of the Long

Long

public Long(String s)
     throws NumberFormatException
Constructs a Long 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 a Long
Throws:
NumberFormatException - If the String does not contain a parsable long.
Method Detail

toString

public static String toString(long i,
                              int radix)
Returns a new String object representing the specified long in the specified radix.

Parameters:
i - the long to be converted
radix - the radix
See Also:
Character.MIN_RADIX, Character.MAX_RADIX

toHexString

public static String toHexString(long i)
Returns a new String object representing the specified long as unsigned hexidecimal number.


toOctalString

public static String toOctalString(long i)
Returns a new String object representing the specified long as unsigned octal number.


toBinaryString

public static String toBinaryString(long i)
Returns a new String object representing the specified long as unsigned octal number.


toString

public static String toString(long i)
Returns a new String object representing the specified integer. The radix is assumed to be 10.

Parameters:
i - the long to be converted

parseLong

public static long parseLong(String s,
                             int radix)
                      throws NumberFormatException
Assuming the specified String represents a long, returns that long's value. Throws an exception if the String cannot be parsed as a long.

Parameters:
s - the String containing the integer
radix - the radix to be used
Throws:
NumberFormatException - If the String does not contain a parsable integer.

parseLong

public static long parseLong(String s)
                      throws NumberFormatException
Assuming the specified String represents a long, return that long's value. Throws an exception if the String cannot be parsed as a long. The radix is assumed to be 10.

Parameters:
s - the String containing the long
Throws:
NumberFormatException - If the string does not contain a parsable long.

valueOf

public static Long valueOf(String s,
                           int radix)
                    throws NumberFormatException
Assuming the specified String represents a long, returns a new Long object initialized to that value. Throws an exception if the String cannot be parsed as a long.

Parameters:
s - the String containing the long.
radix - the radix to be used
Throws:
NumberFormatException - If the String does not contain a parsable long.

valueOf

public static Long valueOf(String s)
                    throws NumberFormatException
Assuming the specified String represents a long, returns a new Long object initialized to that value. Throws an exception if the String cannot be parsed as a long. The radix is assumed to be 10.

Parameters:
s - the String containing the long
Throws:
NumberFormatException - If the String does not contain a parsable long.

intValue

public int intValue()
Returns the value of this Long as an int.

Specified by:
intValue in class Number

longValue

public long longValue()
Returns the value of this Long as a long.

Specified by:
longValue in class Number

floatValue

public float floatValue()
Returns the value of this Long as a float.

Specified by:
floatValue in class Number

doubleValue

public double doubleValue()
Returns the value of this Long as a double.

Specified by:
doubleValue in class Number

toString

public String toString()
Returns a String object representing this Long's value.

Overrides:
toString in class Object

hashCode

public int hashCode()
Computes a hashcode for this Long.

Overrides:
hashCode in class Object
See Also:
Hashtable

equals

public boolean equals(Object obj)
Compares this object against the specified object.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.
See Also:
Hashtable

getLong

public static Long getLong(String nm)
Gets a Long property. If the property does not exist, it will return 0.

Parameters:
nm - the property name

getLong

public static Long getLong(String nm,
                           long val)
Gets a Long property. If the property does not exist, it will return val. Deals with Hexadecimal and octal numbers.

Parameters:
nm - the String name
val - the Long value

getLong

public static Long getLong(String nm,
                           Long val)
Gets a Long property. If the property does not exist, it will return val. Deals with Hexadecimal and octal numbers.

Parameters:
nm - the property name
val - the Long value