Long class Methods in Java Part -II

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.parseLong(CharSequence s, int beginIndex, int endIndex, int radix)It parses the CharSequence argument as a signed long in the specified radix, beginning at the beginIndex and extending to endIndex - 1.


Long.parseUnsignedLong(String s)It parses the string argument as an unsigned decimal long.


Long.parseUnsignedLong(String s, int radix)It parses the string argument as an unsigned long in the radix specified by the second argument.


Long.parseUnsignedLong(CharSequence s, int beginIndex, int endIndex, int radix)It parses the CharSequence argument as an unsigned long in the specified radix, beginning at the beginIndex and extending to endIndex - 1.


Long.remainderUnsigned()It returns the unsigned remainder from dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.


Long.reverse(): It returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specified long value.


Long.reverseBytes()It returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified long value.


Long.rotateLeft() It returns the value obtained by rotating the two's complement binary representation of the specified long value left by the specified number of bits.


Long.rotateRight()It returns the value obtained by rotating the two's complement binary representation of the specified long value right by the specified number of bits.


Long.signum()It returns the signum function of the specified long value.


Long.SIZEThe number of bits used to represent a long value in twos complements binary form (i.e 64).


Long.sum() It adds two long values together as per the + operator.


Long.toBinaryString()It returns a string representation of the long argument as an unsigned integer in base 2.


Long.toHexString()It returns a string representation of the long argument as an unsigned integer in base 16.


Long.toOctalString()It returns a string representation of the long argument as an unsigned integer in base 8.


Long.toString(long i)It returns a String object representing the specified long. 


Long.toString(long i, int radix)It returns a string representation of the first argument in the radix specified by the second argument.


Long.toUnsignedString()It returns a string representation of the argument as an unsigned decimal value.


Long.valueOf(long l): It returns a Long instance representing the specified long value. 


Long.valueOf(String s): It returns a Long object holding the value of the specified String.


Long.valueOf(String s, int radix)It returns a Long object holding the value extracted from the specified String when parsed with the radix given by the second argument.


Some more Methods of Long Part - I


No comments:

Post a Comment