Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#pubctors) \| [Methods](https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#inhmethods)

# AtomicLongArray

` public class AtomicLongArray `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/io/Serializable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.util.concurrent.atomic.AtomicLongArray |

<br />

*** ** * ** ***

A `long` array in which elements may be updated atomically. See the `https://developer.android.com/reference/java/lang/invoke/VarHandle` specification for descriptions of the properties of atomic accesses.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#AtomicLongArray(int)(int length) ` Creates a new AtomicLongArray of the given length, with all elements initially zero. |
| ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#AtomicLongArray(long[])(long[] array) ` Creates a new AtomicLongArray with the same length as, and all elements copied from, the given array. |

| ### Public methods ||
|---|---|
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#accumulateAndGet(int,%20long,%20java.util.function.LongBinaryOperator)(int i, long x, https://developer.android.com/reference/java/util/function/LongBinaryOperator accumulatorFunction) ` Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function to the current and given values, returning the updated value. |
| ` long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#addAndGet(int,%20long)(int i, long delta) ` Atomically adds the given value to the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndExchange(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Atomically sets the element at index `i` to `newValue` if the element's current value, referred to as the *witness value* , `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndExchange(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndExchangeAcquire(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Atomically sets the element at index `i` to `newValue` if the element's current value, referred to as the *witness value* , `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndExchangeAcquire(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndExchangeRelease(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Atomically sets the element at index `i` to `newValue` if the element's current value, referred to as the *witness value* , `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndExchangeRelease(java.lang.Object[])`. |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndSet(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#decrementAndGet(int)(int i) ` Atomically decrements the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#get(int)(int i) ` Returns the current value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getVolatile(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAcquire(int)(int i) ` Returns the current value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAcquire(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAndAccumulate(int,%20long,%20java.util.function.LongBinaryOperator)(int i, long x, https://developer.android.com/reference/java/util/function/LongBinaryOperator accumulatorFunction) ` Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function to the current and given values, returning the previous value. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAndAdd(int,%20long)(int i, long delta) ` Atomically adds the given value to the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAndDecrement(int)(int i) ` Atomically decrements the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAndIncrement(int)(int i) ` Atomically increments the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAndSet(int,%20long)(int i, long newValue) ` Atomically sets the element at index `i` to `newValue` and returns the old value, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndSet(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getAndUpdate(int,%20java.util.function.LongUnaryOperator)(int i, https://developer.android.com/reference/java/util/function/LongUnaryOperator updateFunction) ` Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function, returning the previous value. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getOpaque(int)(int i) ` Returns the current value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getOpaque(java.lang.Object[])`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#getPlain(int)(int i) ` Returns the current value of the element at index `i`, with memory semantics of reading as if the variable was declared non-`volatile`. |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#incrementAndGet(int)(int i) ` Atomically increments the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`. |
| ` final void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#lazySet(int,%20long)(int i, long newValue) ` Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setRelease(java.lang.Object[])`. |
| ` final int` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#length()() ` Returns the length of the array. |
| ` final void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#set(int,%20long)(int i, long newValue) ` Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setVolatile(java.lang.Object[])`. |
| ` final void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#setOpaque(int,%20long)(int i, long newValue) ` Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setOpaque(java.lang.Object[])`. |
| ` final void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#setPlain(int,%20long)(int i, long newValue) ` Sets the element at index `i` to `newValue`, with memory semantics of setting as if the variable was declared non-`volatile` and non-`final`. |
| ` final void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#setRelease(int,%20long)(int i, long newValue) ` Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setRelease(java.lang.Object[])`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#toString()() ` <br /> |
| ` final long` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#updateAndGet(int,%20java.util.function.LongUnaryOperator)(int i, https://developer.android.com/reference/java/util/function/LongUnaryOperator updateFunction) ` Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function, returning the updated value. |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSet(int,%20long,%20long)(int i, long expectedValue, long newValue) ` *This method was deprecated in API level 33. This method has plain memory effects but the method name implies volatile memory effects (see methods such as `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndExchange(int,%20long,%20long)` and `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndSet(int,%20long,%20long)`). To avoid confusion over plain or volatile memory effects it is recommended that the method `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetPlain(int,%20long,%20long)` be used instead.* |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetAcquire(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetAcquire(java.lang.Object[])`. |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetPlain(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetPlain(java.lang.Object[])`. |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetRelease(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetRelease(java.lang.Object[])`. |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetVolatile(int,%20long,%20long)(int i, long expectedValue, long newValue) ` Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSet(java.lang.Object[])`. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### AtomicLongArray

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AtomicLongArray (int length)
```

Creates a new AtomicLongArray of the given length, with all elements initially zero.

<br />

| Parameters ||
|---|---|
| `length` | `int`: the length of the array <br /> |

### AtomicLongArray

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AtomicLongArray (long[] array)
```

Creates a new AtomicLongArray with the same length as, and all elements copied from, the given array.

<br />

| Parameters ||
|---|---|
| `array` | `long`: the array to copy elements from <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if array is null |

## Public methods

### accumulateAndGet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long accumulateAndGet (int i, 
                long x, 
                LongBinaryOperator accumulatorFunction)
```

Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function to the current and given values, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value of the element at index `i` as its first argument, and the given update as the second argument.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `x` | `long`: the update value <br /> |
| `accumulatorFunction` | `LongBinaryOperator`: a side-effect-free function of two arguments <br /> |

| Returns ||
|---|---|
| `long` | the updated value <br /> |

### addAndGet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long addAndGet (int i, 
                long delta)
```

Atomically adds the given value to the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `delta` | `long`: the value to add <br /> |

| Returns ||
|---|---|
| `long` | the updated value <br /> |

### compareAndExchange

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long compareAndExchange (int i, 
                long expectedValue, 
                long newValue)
```

Atomically sets the element at index `i` to `newValue` if the element's current value, referred to as the *witness value* , `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndExchange(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `long` | the *witness value* , which will be the same as the expected value if successful <br /> |

### compareAndExchangeAcquire

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long compareAndExchangeAcquire (int i, 
                long expectedValue, 
                long newValue)
```

Atomically sets the element at index `i` to `newValue` if the element's current value, referred to as the *witness value* , `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndExchangeAcquire(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `long` | the *witness value* , which will be the same as the expected value if successful <br /> |

### compareAndExchangeRelease

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long compareAndExchangeRelease (int i, 
                long expectedValue, 
                long newValue)
```

Atomically sets the element at index `i` to `newValue` if the element's current value, referred to as the *witness value* , `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndExchangeRelease(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `long` | the *witness value* , which will be the same as the expected value if successful <br /> |

### compareAndSet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean compareAndSet (int i, 
                long expectedValue, 
                long newValue)
```

Atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if successful. False return indicates that the actual value was not equal to the expected value. <br /> |

### decrementAndGet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long decrementAndGet (int i)
```

Atomically decrements the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`.

Equivalent to `addAndGet(i, -1)`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the updated value <br /> |

### get

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long get (int i)
```

Returns the current value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getVolatile(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the current value <br /> |

### getAcquire

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAcquire (int i)
```

Returns the current value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAcquire(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the value <br /> |

### getAndAccumulate

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAndAccumulate (int i, 
                long x, 
                LongBinaryOperator accumulatorFunction)
```

Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function to the current and given values, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value of the element at index `i` as its first argument, and the given update as the second argument.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `x` | `long`: the update value <br /> |
| `accumulatorFunction` | `LongBinaryOperator`: a side-effect-free function of two arguments <br /> |

| Returns ||
|---|---|
| `long` | the previous value <br /> |

### getAndAdd

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAndAdd (int i, 
                long delta)
```

Atomically adds the given value to the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `delta` | `long`: the value to add <br /> |

| Returns ||
|---|---|
| `long` | the previous value <br /> |

### getAndDecrement

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAndDecrement (int i)
```

Atomically decrements the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`.

Equivalent to `getAndAdd(i, -1)`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the previous value <br /> |

### getAndIncrement

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAndIncrement (int i)
```

Atomically increments the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`.

Equivalent to `getAndAdd(i, 1)`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the previous value <br /> |

### getAndSet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAndSet (int i, 
                long newValue)
```

Atomically sets the element at index `i` to `newValue` and returns the old value, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndSet(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `long` | the previous value <br /> |

### getAndUpdate

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getAndUpdate (int i, 
                LongUnaryOperator updateFunction)
```

Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `updateFunction` | `LongUnaryOperator`: a side-effect-free function <br /> |

| Returns ||
|---|---|
| `long` | the previous value <br /> |

### getOpaque

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getOpaque (int i)
```

Returns the current value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getOpaque(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the value <br /> |

### getPlain

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long getPlain (int i)
```

Returns the current value of the element at index `i`, with memory semantics of reading as if the variable was declared non-`volatile`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the value <br /> |

### incrementAndGet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long incrementAndGet (int i)
```

Atomically increments the value of the element at index `i`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#getAndAdd(java.lang.Object[])`.

Equivalent to `addAndGet(i, 1)`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |

| Returns ||
|---|---|
| `long` | the updated value <br /> |

### lazySet

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final void lazySet (int i, 
                long newValue)
```

Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setRelease(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `newValue` | `long`: the new value <br /> |

### length

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final int length ()
```

Returns the length of the array.

<br />

| Returns ||
|---|---|
| `int` | the length of the array <br /> |

### set

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final void set (int i, 
                long newValue)
```

Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setVolatile(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `newValue` | `long`: the new value <br /> |

### setOpaque

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final void setOpaque (int i, 
                long newValue)
```

Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setOpaque(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `newValue` | `long`: the new value <br /> |

### setPlain

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final void setPlain (int i, 
                long newValue)
```

Sets the element at index `i` to `newValue`, with memory semantics of setting as if the variable was declared non-`volatile` and non-`final`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `newValue` | `long`: the new value <br /> |

### setRelease

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final void setRelease (int i, 
                long newValue)
```

Sets the element at index `i` to `newValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#setRelease(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `newValue` | `long`: the new value <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the String representation of the current values of array <br /> |

### updateAndGet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final long updateAndGet (int i, 
                LongUnaryOperator updateFunction)
```

Atomically updates (with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#compareAndSet(java.lang.Object[])`) the element at index `i` with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `updateFunction` | `LongUnaryOperator`: a side-effect-free function <br /> |

| Returns ||
|---|---|
| `long` | the updated value <br /> |

### weakCompareAndSet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean weakCompareAndSet (int i, 
                long expectedValue, 
                long newValue)
```

<br />

**This method was deprecated in API level 33.**   

This method has plain memory effects but the method name implies volatile memory effects (see methods such as `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndExchange(int,%20long,%20long)` and `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#compareAndSet(int,%20long,%20long)`). To avoid confusion over plain or volatile memory effects it is recommended that the method `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetPlain(int,%20long,%20long)` be used instead.

Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetPlain(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if successful <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicLongArray#weakCompareAndSetPlain(int,%20long,%20long)`

### weakCompareAndSetAcquire

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean weakCompareAndSetAcquire (int i, 
                long expectedValue, 
                long newValue)
```

Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetAcquire(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if successful <br /> |

### weakCompareAndSetPlain

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean weakCompareAndSetPlain (int i, 
                long expectedValue, 
                long newValue)
```

Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetPlain(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if successful <br /> |

### weakCompareAndSetRelease

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean weakCompareAndSetRelease (int i, 
                long expectedValue, 
                long newValue)
```

Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSetRelease(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if successful <br /> |

### weakCompareAndSetVolatile

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean weakCompareAndSetVolatile (int i, 
                long expectedValue, 
                long newValue)
```

Possibly atomically sets the element at index `i` to `newValue` if the element's current value `== expectedValue`, with memory effects as specified by `https://developer.android.com/reference/java/lang/invoke/VarHandle#weakCompareAndSet(java.lang.Object[])`.

<br />

| Parameters ||
|---|---|
| `i` | `int`: the index <br /> |
| `expectedValue` | `long`: the expected value <br /> |
| `newValue` | `long`: the new value <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if successful <br /> |