Java Long Class Methods

The Long class in Java is a wrapper class for the primitive data type long. It provides several useful methods for working with long values, such as parsing, comparing, and converting to other data types. Understanding these methods can help you perform common tasks more efficiently in your Java programs.

This guide covers various methods available in the Long class. Each method is described in simple terms to help beginners understand how to use them. These methods enable you to perform operations like bit manipulation, conversion between different bases, and arithmetic operations.

For more detailed information, please refer to the official Java SE Documentation and additional resources on Java Wrapper Classes Tutorial.

Java Long Class Methods

The table below contains various methods of the Java Long class, each with a link to a detailed explanation, examples, and real-world uses. Click on the method names to learn more about how to use them effectively in your applications.

Method Description
bitCount() Returns the number of one-bits in the two's complement binary representation of the specified long value.
byteValue() Converts this Long to 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() Converts this Long to a short.
toString() Returns a string representation of the long argument as a signed decimal long.
valueOf() Returns a Long instance representing the specified long value.
sum() Returns the sum of its arguments.

Comments