Module java.base
Package java.lang

# Class Long

≠
public final class Long
extends java.lang.Number
implements java.lang.Comparable<java.lang.Long>, java.lang.constant.Constable, java.lang.constant.ConstantDesc
Comparing jdk-master and valhalla-csr-open

All Implemented Interfaces:
  `Serializable, Comparable<Long>, Constable, ConstantDesc`

public final class Long extends Number implements Comparable<Long>, Constable, ConstantDesc
The `Long` class is the wrapper class for values of the primitive type `long` . 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` .

This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail mutexes, or with object references.

When preview features are enabled, `Long` is a value classPREVIEW . Use of value class instances for synchronization, mutexes, or with object references result in `IdentityException` PREVIEW Moved out of a paragraph.Moved to a division with class preview-block.Moved to a division with class preview-comment..

Implementation note: The implementations of the "bit twiddling" methods (such as `highestOneBit` and `numberOfTrailingZeros` ) are based on material from Henry S. Warren, Jr.'s Hacker's Delight , (Addison Wesley, 2002) and Hacker's Delight, Second Edition , (Pearson Education, 2013).

Since:
  1.0
See Also:
  - Serialized Form

## Fields

- =
  public static final int BYTES = 8
- =
  public static final long MAX_VALUE = 9223372036854775807
- =
  public static final long MIN_VALUE = -9223372036854775808
- =
  public static final int SIZE = 64
- =
  public static final java.lang.Class<java.lang.Long> TYPE

## Constructors

- =
  @Deprecated(since="9")
  public Long(long arg0)
- =
  @Deprecated(since="9")
  public Long(java.lang.String arg0) throws java.lang.NumberFormatException

## Methods

- =
  public static int bitCount(long arg0)
- =
  public byte byteValue()
- =
  public static int compare(long arg0, long arg1)
- =
  public int compareTo(java.lang.Long arg0)
- =
  public static int compareUnsigned(long arg0, long arg1)
- =
  public static long compress(long arg0, long arg1)
- =
  public static java.lang.Long decode(java.lang.String arg0) throws java.lang.NumberFormatException
- =
  public java.util.Optional<java.lang.Long> describeConstable()
- =
  public static long divideUnsigned(long arg0, long arg1)
- =
  public double doubleValue()
- =
  public boolean equals(java.lang.Object arg0)
- =
  public static long expand(long arg0, long arg1)
- =
  public float floatValue()
- =
  public static java.lang.Long getLong(java.lang.String arg0)
- =
  public static java.lang.Long getLong(java.lang.String arg0, long arg1)
- =
  public static java.lang.Long getLong(java.lang.String arg0, java.lang.Long arg1)
- =
  public int hashCode()
- =
  public static int hashCode(long arg0)
- =
  public static long highestOneBit(long arg0)
- =
  public int intValue()
- =
  public long longValue()
- =
  public static long lowestOneBit(long arg0)
- =
  public static long max(long arg0, long arg1)
- =
  public static long min(long arg0, long arg1)
- =
  public static int numberOfLeadingZeros(long arg0)
- =
  public static int numberOfTrailingZeros(long arg0)
- =
  public static long parseLong(java.lang.CharSequence arg0, int arg1, int arg2, int arg3) throws java.lang.NumberFormatException
- =
  public static long parseLong(java.lang.String arg0) throws java.lang.NumberFormatException
- =
  public static long parseLong(java.lang.String arg0, int arg1) throws java.lang.NumberFormatException
- =
  public static long parseUnsignedLong(java.lang.CharSequence arg0, int arg1, int arg2, int arg3) throws java.lang.NumberFormatException
- =
  public static long parseUnsignedLong(java.lang.String arg0) throws java.lang.NumberFormatException
- =
  public static long parseUnsignedLong(java.lang.String arg0, int arg1) throws java.lang.NumberFormatException
- =
  public static long remainderUnsigned(long arg0, long arg1)
- =
  public java.lang.Long resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup arg0)
- =
  public static long reverse(long arg0)
- =
  public static long reverseBytes(long arg0)
- =
  public static long rotateLeft(long arg0, int arg1)
- =
  public static long rotateRight(long arg0, int arg1)
- =
  public short shortValue()
- =
  public static int signum(long arg0)
- =
  public static long sum(long arg0, long arg1)
- =
  public static java.lang.String toBinaryString(long arg0)
- =
  public static java.lang.String toHexString(long arg0)
- =
  public static java.lang.String toOctalString(long arg0)
- =
  public java.lang.String toString()
- =
  public static java.lang.String toString(long arg0)
- =
  public static java.lang.String toString(long arg0, int arg1)
- =
  public static java.lang.String toUnsignedString(long arg0)
- =
  public static java.lang.String toUnsignedString(long arg0, int arg1)
- ≠
  public static java.lang.Long valueOf(long arg0)
  Comparing jdk-master and valhalla-csr-open

  ### valueOf

  public static Long valueOf (long l)
  Returns a `Long` instance representing the specified `long` value.

  - When preview features are NOT enabled, `Long` is an identity class. Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.If a new `Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.Long` Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph. instance is not required, this method should generally be used in preference to the constructor `Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph.Long(long)` Moved to a division with class preview-block.Moved to a division with class preview-comment.Moved to a paragraph., as this method is likely to yield significantly better space and time performance by caching frequently requested values. This method will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range.

  - When preview features are enabled, `Long` is a value classPREVIEW . The `valueOf` behavior is the same as invoking the constructor, whether cached or not.

  Parameters:
    `l` - a long value.
  Returns:
    a `Long` instance representing `l` .
  Since:
    1.5
- =
  public static java.lang.Long valueOf(java.lang.String arg0) throws java.lang.NumberFormatException
- =
  public static java.lang.Long valueOf(java.lang.String arg0, int arg1) throws java.lang.NumberFormatException

## Serialized Form

=

### serialVersionUID

=4290774380558885855

### Serialized Fields

- =
  long value

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
Long |  |  |  |  |  |  | 7 | 2 |  | 9
valueOf(long) |  |  |  |  |  |  | 6 | 3 |  | 9
Total |  |  |  |  |  |  | 13 | 5 |  | 18