Long class Methods in Java Part -I

java.lang.Long

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


Some Methods of Long Class.


Long.bitCount()It returns the number of one-bits in the two's complement binary representation of the specified long value.


Long.BYTESThe number of bytes is used to represent a long value in twos complements binary form (i.e 8).


Long.compare()It compares two long values numerically.


Long.compareUnsigned()It compares two long values numerically treating the values as unsigned.


Long.decode()It decodes a String into a Long. Accepts decimal, hexadecimal, and octal numbers.


Long.divideUnsigned()It returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.


Long.getLong(String nm)It determines the long value of the system property with the specified name.


Long.getLong(String nm, long val)It determines the long value of the system property with the specified name.


Long.getLong(String nm, Long val)It returns the long value of the system property with the specified name. The first argument is treated as the name of a system property.


Long.hashCode()It returns a hash code for a long value.


Long.highestOneBit()It returns a long value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified long value.


Long.lowestOneBit()It returns a long value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified long value.


Long.max()It returns the greater of two long values.


Long.MAX_VALUEA constant holding the maximum value long can have, 2^63-1.


Long.min() It returns the smaller of two long values.


Long.MIN_VALUEA constant holding the minimum value long can have, -2^63.


Long.numberOfLeadingZeros()It returns the number of zero bits preceding the highest-order("leftmost")  one-bit in the two's complement binary representation of the specified long value.


Long.numberOfTrailingZeros() It returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long value.


Long.parseLong(String s)It parses the string argument as a signed decimal long.


Long.parseLong(String s, int radix)It parses the string argument as a signed long in the radix specified by the second argument.


Some more Methods of Long Part -II


No comments:

Post a Comment