Name

Long

Synopsis

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.

java.lang.Long

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> ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.