public final class Long extends Number implements Comparable<Long>
Long
class wraps a value of the primitive type long
in an object. An object of type Long
contains a
single field whose type is long
.
In addition, this class provides several methods for converting
a long
to a String
and a String
to a long
, as well as other constants and methods useful when dealing
with a long
.
Implementation note: The implementations of the "bit twiddling"
methods (such as highestOneBit
and
numberOfTrailingZeros
) are
based on material from Henry S. Warren, Jr.'s Hacker's
Delight, (Addison Wesley, 2002).
Modifier and Type  Field and Description 

static int 
BYTES
The number of bytes used to represent a
long value in two's
complement binary form. 
static long 
MAX_VALUE
A constant holding the maximum value a
long can
have, 2^{63}1. 
static long 
MIN_VALUE
A constant holding the minimum value a
long can
have, 2^{63}. 
static int 
SIZE
The number of bits used to represent a
long value in two's
complement binary form. 
static Class<Long> 
TYPE
The
Class instance representing the primitive type
long . 
Constructor and Description 

Long(long value)
Constructs a newly allocated
Long object that
represents the specified long argument. 
Long(String s)
Constructs a newly allocated
Long object that
represents the long value indicated by the
String parameter. 
Modifier and Type  Method and Description 

static int 
bitCount(long i)
Returns the number of onebits in the two's complement binary
representation of the specified
long value. 
byte 
byteValue()
Returns the value of this
Long as a byte after
a narrowing primitive conversion. 
static int 
compare(long x,
long y)
Compares two
long values numerically. 
int 
compareTo(Long anotherLong)
Compares two
Long objects numerically. 
static int 
compareUnsigned(long x,
long y)
Compares two
long values numerically treating the values
as unsigned. 
static Long 
decode(String nm)
Decodes a
String into a Long . 
static long 
divideUnsigned(long dividend,
long divisor)
Returns the unsigned quotient of dividing the first argument by
the second where each argument and the result is interpreted as
an unsigned value.

double 
doubleValue()
Returns the value of this
Long as a double
after a widening primitive conversion. 
boolean 
equals(Object obj)
Compares this object to the specified object.

float 
floatValue()
Returns the value of this
Long as a float after
a widening primitive conversion. 
static Long 
getLong(String nm)
Determines the
long value of the system property
with the specified name. 
static Long 
getLong(String nm,
long val)
Determines the
long value of the system property
with the specified name. 
static Long 
getLong(String nm,
Long val)
Returns the
long value of the system property with
the specified name. 
int 
hashCode()
Returns a hash code for this
Long . 
static int 
hashCode(long value)
Returns a hash code for a
long value; compatible with
Long.hashCode() . 
static long 
highestOneBit(long i)
Returns a
long value with at most a single onebit, in the
position of the highestorder ("leftmost") onebit in the specified
long value. 
int 
intValue()
Returns the value of this
Long as an int after
a narrowing primitive conversion. 
long 
longValue()
Returns the value of this
Long as a
long value. 
static long 
lowestOneBit(long i)
Returns a
long value with at most a single onebit, in the
position of the lowestorder ("rightmost") onebit in the specified
long value. 
static long 
max(long a,
long b)
Returns the greater of two
long values
as if by calling Math.max . 
static long 
min(long a,
long b)
Returns the smaller of two
long values
as if by calling Math.min . 
static int 
numberOfLeadingZeros(long i)
Returns the number of zero bits preceding the highestorder
("leftmost") onebit in the two's complement binary representation
of the specified
long value. 
static int 
numberOfTrailingZeros(long i)
Returns the number of zero bits following the lowestorder ("rightmost")
onebit in the two's complement binary representation of the specified
long value. 
static long 
parseLong(String s)
Parses the string argument as a signed decimal
long . 
static long 
parseLong(String s,
int radix)
Parses the string argument as a signed
long in the
radix specified by the second argument. 
static long 
parseUnsignedLong(String s)
Parses the string argument as an unsigned decimal
long . 
static long 
parseUnsignedLong(String s,
int radix)
Parses the string argument as an unsigned
long in the
radix specified by the second argument. 
static long 
remainderUnsigned(long dividend,
long divisor)
Returns the unsigned remainder from dividing the first argument
by the second where each argument and the result is interpreted
as an unsigned value.

static long 
reverse(long i)
Returns the value obtained by reversing the order of the bits in the
two's complement binary representation of the specified
long
value. 
static long 
reverseBytes(long i)
Returns the value obtained by reversing the order of the bytes in the
two's complement representation of the specified
long value. 
static long 
rotateLeft(long i,
int distance)
Returns the value obtained by rotating the two's complement binary
representation of the specified
long value left by the
specified number of bits. 
static long 
rotateRight(long i,
int distance)
Returns the value obtained by rotating the two's complement binary
representation of the specified
long value right by the
specified number of bits. 
short 
shortValue()
Returns the value of this
Long as a short after
a narrowing primitive conversion. 
static int 
signum(long i)
Returns the signum function of the specified
long value. 
static long 
