Team LiB
Previous Section Next Section

Longjava.lang

Java 1.0serializable comparable

This class provides an immutable object wrapper around the long primitive data type. This class also contains useful minimum and maximum constants and useful conversion methods. parseLong( ) and valueOf( ) convert a string to a long or to a Long, respectively. Each can take a radix argument to specify the base the value is represented in. toString( ) converts in the other direction and may also take a radix argument. toBinaryString( ), toOctalString( ), and toHexString( ) convert a long to a string using base 2, base 8, and base 16. These methods treat the long as an unsigned value. Other routines return the value of a Long as various primitive types, and, finally, the getLong( ) methods return the long value of a named property or the value of the specified default.

Java 5.0 adds a number of static methods that operate on the bits of a long value. Except for their argument type and return type, they are the same as the Integer methods of the same name.

Figure 10-39. java.lang.Long


public final class Long extends Number implements Comparable<Long> {
// Public Constructors
     public Long(long value);  
     public Long(String s) throws NumberFormatException;  
// Public Constants
     public static final long MAX_VALUE;   =9223372036854775807
     public static final long MIN_VALUE;   =-9223372036854775808
5.0  public static final int SIZE;     =64
1.1  public static final Class<Long> TYPE;  
// Public Class Methods
5.0  public static int bitCount(long i);  
1.2  public static Long decode(String nm) throws NumberFormatException;  
     public static Long getLong(String nm);  
     public static Long getLong(String nm, Long val);  
     public static Long getLong(String nm, long val);  
5.0  public static long highestOneBit(long i);  
5.0  public static long lowestOneBit(long i);  
5.0  public static int numberOfLeadingZeros(long i);  
5.0  public static int numberOfTrailingZeros(long i);  
     public static long parseLong(String s) throws NumberFormatException;  
     public static long parseLong(String s, int radix) throws NumberFormatException;  
5.0  public static long reverse(long i);  
5.0  public static long reverseBytes(long i);  
5.0  public static long rotateLeft(long i, int distance);  
5.0  public static long rotateRight(long i, int distance);  
5.0  public static int signum(long i);  
     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);  
5.0  public static Long valueOf(long l);  
     public static Long valueOf(String s) throws NumberFormatException;  
     public static Long valueOf(String s, int radix) throws NumberFormatException;  
// Methods Implementing Comparable
1.2  public int compareTo(Long anotherLong);  
// Public Methods Overriding Number
1.1  public byte byteValue( );  
     public double doubleValue( );  
     public float floatValue( );  
     public int intValue( );  
     public long longValue( );  
1.1  public short shortValue( );  
// Public Methods Overriding Object
     public boolean equals(Object obj);  
     public int hashCode( );  
     public String toString( );  
}

    Team LiB
    Previous Section Next Section