Long

Name

Long

Synopsis

Description

The Long class provides an object wrapper for a long value. This is useful when you need to treat a long value as an object. For example, there are a number of utility methods that take a reference to an Object as one of their arguments. You cannot specify a long value for one of these arguments, but you can provide a reference to a Long object that encapsulates the long value. Furthermore, as of JDK 1.1, the Long class is necessary to support the Reflection API and class literals.

The Long class also provides a number of utility methods for converting long values to other primitive types and for converting long values to strings and vice versa.

Class Summary

public final class java.lang.Long extends java.lang.Number {
 // Constants public static final long MIN_VALUE;
public static final long MAX_VALUE;
public final static Class TYPE; // New in 1.1 // Constructors public Long(long value);
public Long(String s); // Class Methods public static Long getLong(String nm);
public static Long getLong(String nm, long val);
public static Long getLong(String nm, Long val);
public static long parseLong(String s);
public static long parseLong(String s, int radix);
public static String toBinaryString(long i);
public static String toHexString(long i);
public static String toOctalString(long i);
public static String toString(long i);
public static String toString(long i, int radix);
public static Long valueOf(String s);
public static Long valueOf(String s, int radix); // Instance Methods public byte byteValue(); // New in 1.1 public double doubleValue();
public boolean equals(Object obj);
public float floatValue();
public int hashCode();
public int intValue();
public long longValue();
public short shortValue(); // New in 1.1 public String toString();
}

Constants

MAX_VALUE

public static final long MAX_VALUE = 0x7fffffffffffffffL

MIN_VALUE

public static final long MIN_VALUE = 0x8000000000000000L

TYPE

public static final Class TYPE

Constructors

Long

public Long(long value)

public Long(String s) throws NumberFormatException

Class Methods

getLong

public static Integer getLong(String nm)

public static Long getLong(String nm, long val)

public static Long getLong(String nm, Long val)

parseLong

public static long parseLong(String s) throws NumberFormatException 

public static long parseLong(String s, int radix) throws NumberFormatException 

toBinaryString

public static String toBinaryString(long value)

toHexString

public static String toHexString(long value)

toOctalString

public static String toOctalString(long value)

toString

public static String toString(long i)

public static String toString(long i, int radix)

valueOf

public static Long valueOf(String s) throws NumberFormatException 

public static Long valueOf(String s, int radix) throws NumberFormatException 

Instance Methods

byteValue

public byte byteValue()

doubleValue

public double doubleValue()

equals

public boolean equals(Object obj)

floatValue

public float floatValue()

hashCode

public int hashCode()

intValue

public int intValue()

longValue

public long longValue()

shortValue

public short shortValue()

toString

public String toString()

Inherited Methods

Method Inherited From Method Inherited From
clone() Object finalize() Object
getClass() Object notify() Object
notifyAll() Object wait() Object
wait(long) Object wait(long, int) Object

See Also

Character; Class; Exceptions; Integer; Integer literals; Integer types; Number; String; System