Name

Long

Synopsis

Long provides an object wrapper for a Java long primitive. The constructor initializes the wrapper with a long value, after which the object is immutable. The value associated with a Long object can be retrieved using the longValue() method.

The static parseLong() converts a numeric value held in a String into a primitive long. The single-argument variant of this method assumes that the String is encoded in base 10; the two-argument variant can be used to specify a different number base if necessary. A NumberFormatException is thrown if the String does not represent a valid number in the given number base.

The zero-argument toString() method returns a String representation of the value of the Long encoded as a base 10 number. There is also a static variant of this method that prints the value of a given long as a base 10 number, as well as a two-argument variant that prints a value using digits from the number base supplied as its second argument.

The static variables Long.MIN_VALUE and Long.MAX_VALUE are long (not Long) values representing the smallest and largest values, respectively, that can be held in a long primitive.

Note that this class is derived from Object and not Number, as it is in the J2SE. This is because the CLDC does not provide the Number class.

public final class Long {  
// Public Constructors
   public Long( long value);  
// Public Constants
   public static final long MAX_VALUE;                    // =9223372036854775807
   public static final long MIN_VALUE;                    // =-9223372036854775808 ...

Get J2ME in a Nutshell 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.