Long class

                             
    java.lang.Object                        
     |                       
     |--java.lang.Number                    
         |                   
         |--java.lang.Long                
                             

The Long class wraps a value of long in an object. Long class provides several methods for converting a long to a String and a String to a long.

Constants value from Long class

TypeFieldSummary
static longMAX_VALUEMaximum value a long can have, 2^63-1.
static longMIN_VALUEMinimum value a long can have, -2^63.
static intSIZEThe number of bits used to represent a long value in two's complement binary form.
static Class<Long>TYPEThe Class instance representing the primitive type long.

Constructors from Long

ConstructorSummary
Long(long value)Creates a Long object from long argument.
Long(String s)Creates a Long object from the long value indicated by the String parameter.

Convert long value to byte, double, float, int, long, short

ReturnMethodSummary
bytebyteValue()Returns the value of this Long as a byte.
doubledoubleValue()Returns the value of this Long as a double.
floatfloatValue()Returns the value of this Long as a float.
intintValue()Returns the value of this Long as an int.
longlongValue()Returns the value of this Long as a long value.
shortshortValue()Returns the value of this Long as a short.

Decode a string to create long value

ReturnMethodSummary
static Longdecode(String nm)Decodes a String into a Long.

Get the long value from a string

ReturnMethodSummary
static LonggetLong(String nm)Determines the long value of the system property with the specified name.
static LonggetLong(String nm, long val)Determines the long value of the system property with the specified name.
static LonggetLong(String nm, Long val)Returns the long value of the system property with the specified name.

Compare two long values

ReturnMethodSummary
intcompareTo(Long anotherLong)Compares two Long objects numerically.
booleanequals(Object obj)Compares this object to the specified object.

Parse long value from string

ReturnMethodSummary
static longparseLong(String s)Parses the string argument as a signed decimal long.
static longparseLong(String s, int radix)Parses the string as a signed long in the radix.
static LongvalueOf(long l)Returns a Long instance representing the specified long value.
static LongvalueOf(String s)Returns a Long object holding the value of the specified String.
static LongvalueOf(String s, int radix)Returns a Long object holding the value extracted from the String with the radix.

Convert long value to binary, hex and octal format strings

ReturnMethodSummary
static StringtoBinaryString(long i)Returns a string representation of the long argument as an unsigned integer in base 2.
static StringtoHexString(long i)Returns a string representation of the long argument as an unsigned integer in base 16.
static StringtoOctalString(long i)Returns a string representation of the long argument as an unsigned integer in base 8.

Convert long value to string

ReturnMethodSummary
StringtoString()Returns a String object representing this Long's value.
static StringtoString(long i)Returns a String object representing the specified long.
static StringtoString(long i, int radix)Returns a string representation of the first argument in the radix.

Get the sign of the long value

ReturnMethodSummary
static intsignum(long i)Returns the signum function of the specified long value.

Get the number of zero bits preceding and following

ReturnMethodSummary
static intnumberOfLeadingZeros(long i)Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation.
static intnumberOfTrailingZeros(long i)Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation.

Reverse and rotate a long value

ReturnMethodSummary
static longreverse(long i)Returns the value obtained by reversing the order of the bits in the two's complement binary representation.
static longreverseBytes(long i)Returns the value obtained by reversing the order of the bytes in the two's complement representation.
static longrotateLeft(long i, int distance)Returns the value obtained by rotating the two's complement binary representation left by the number of bits.
static longrotateRight(long i, int distance)Returns the value obtained by rotating the two's complement binary representation right by the number of bits.

Bit oriented operation on long value

ReturnMethodSummary
static intbitCount(long i)Returns the number of one-bits in the two's complement binary representation of the specified long value.
static longhighestOneBit(long i)Returns a long value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit.
static longlowestOneBit(long i)Returns a long value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.