Java Long Class Methods

The Long class in Java is a wrapper class for the primitive type long. It provides a variety of 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. Understanding these methods is crucial for efficient long manipulation in Java.

This guide covers various methods available in the Long class, offering a comprehensive understanding of how to manipulate and interact with long values in Java. These methods are essential for efficient coding practices and help in performing operations like parsing, comparing, and converting long values.

For more detailed information, you can refer to the official Java SE Documentation and additional resources on Java Programming Tutorial.

Java Long Class Methods

Method Description
bitCount() Returns the number of one-bits in the two’s complement binary representation of the specified long value.
byteValue() Returns the value of this Long as a byte.
doubleValue() Returns the value of this Long as a double.
floatValue() Returns the value of this Long as a float.
getLong() Determines the long value of the system property with the specified name.
longValue() Returns the value of this Long as a long.
parseLong() Parses the string argument as a signed decimal long.
reverse() Returns the value obtained by reversing the order of the bits in the two’s complement binary representation of the specified long value.
shortValue() Returns the value of this Long as a short.
toString() Returns a string representation of this Long value.
valueOf() Returns a Long instance representing the specified long value.
sum() Returns the sum of two long values as per the + operator.

Leave a Comment

Scroll to Top