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/AtomicReferenceArray#pubctors) \| [Methods](https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#inhmethods)

# AtomicReferenceArray

` public class AtomicReferenceArray `   
` 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.AtomicReferenceArray\<E\> |

<br />

*** ** * ** ***

An array of object references 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/AtomicReferenceArray#AtomicReferenceArray(E[])(E[] array) ` Creates a new AtomicReferenceArray with the same length as, and all elements copied from, the given array. |
| ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#AtomicReferenceArray(int)(int length) ` Creates a new AtomicReferenceArray of the given length, with all elements initially null. |

| ### Public methods ||
|---|---|
| ` final E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#accumulateAndGet(int,%20E,%20java.util.function.BinaryOperator<E>)(int i, E x, https://developer.android.com/reference/java/util/function/BinaryOperator<E> 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. |
| ` final E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#compareAndExchange(int,%20E,%20E)(int i, E expectedValue, E 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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#compareAndExchangeAcquire(int,%20E,%20E)(int i, E expectedValue, E 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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#compareAndExchangeRelease(int,%20E,%20E)(int i, E expectedValue, E 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/AtomicReferenceArray#compareAndSet(int,%20E,%20E)(int i, E expectedValue, E 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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#getAndAccumulate(int,%20E,%20java.util.function.BinaryOperator<E>)(int i, E x, https://developer.android.com/reference/java/util/function/BinaryOperator<E> 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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#getAndSet(int,%20E)(int i, E 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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#getAndUpdate(int,%20java.util.function.UnaryOperator<E>)(int i, https://developer.android.com/reference/java/util/function/UnaryOperator<E> 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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#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 E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#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 void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#lazySet(int,%20E)(int i, E 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/AtomicReferenceArray#length()() ` Returns the length of the array. |
| ` final void` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#set(int,%20E)(int i, E 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/AtomicReferenceArray#setOpaque(int,%20E)(int i, E 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/AtomicReferenceArray#setPlain(int,%20E)(int i, E 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/AtomicReferenceArray#setRelease(int,%20E)(int i, E 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/AtomicReferenceArray#toString()() ` <br /> |
| ` final E` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#updateAndGet(int,%20java.util.function.UnaryOperator<E>)(int i, https://developer.android.com/reference/java/util/function/UnaryOperator<E> 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/AtomicReferenceArray#weakCompareAndSet(int,%20E,%20E)(int i, E expectedValue, E 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/AtomicReferenceArray#compareAndExchange(int,%20E,%20E)` and `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#compareAndSet(int,%20E,%20E)`). To avoid confusion over plain or volatile memory effects it is recommended that the method `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#weakCompareAndSetPlain(int,%20E,%20E)` be used instead.* |
| ` final boolean` | ` https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#weakCompareAndSetAcquire(int,%20E,%20E)(int i, E expectedValue, E 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/AtomicReferenceArray#weakCompareAndSetPlain(int,%20E,%20E)(int i, E expectedValue, E 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/AtomicReferenceArray#weakCompareAndSetRelease(int,%20E,%20E)(int i, E expectedValue, E 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/AtomicReferenceArray#weakCompareAndSetVolatile(int,%20E,%20E)(int i, E expectedValue, E 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

### AtomicReferenceArray

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

```
public AtomicReferenceArray (E[] array)
```

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

<br />

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

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

### AtomicReferenceArray

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

```
public AtomicReferenceArray (int length)
```

Creates a new AtomicReferenceArray of the given length, with all elements initially null.

<br />

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

## Public methods

### accumulateAndGet

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

```
public final E accumulateAndGet (int i, 
                E x, 
                BinaryOperator<E> 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` | `E`: the update value <br /> |
| `accumulatorFunction` | `BinaryOperator`: a side-effect-free function of two arguments <br /> |

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

### compareAndExchange

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

```
public final E compareAndExchange (int i, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: the new value <br /> |

| Returns ||
|---|---|
| `E` | 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 E compareAndExchangeAcquire (int i, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: the new value <br /> |

| Returns ||
|---|---|
| `E` | 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 E compareAndExchangeRelease (int i, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: the new value <br /> |

| Returns ||
|---|---|
| `E` | 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, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: the new value <br /> |

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

### get

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

```
public final E 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 ||
|---|---|
| `E` | the current value <br /> |

### getAcquire

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

```
public final E 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 ||
|---|---|
| `E` | the value <br /> |

### getAndAccumulate

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

```
public final E getAndAccumulate (int i, 
                E x, 
                BinaryOperator<E> 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` | `E`: the update value <br /> |
| `accumulatorFunction` | `BinaryOperator`: a side-effect-free function of two arguments <br /> |

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

### getAndSet

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

```
public final E getAndSet (int i, 
                E 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` | `E`: the new value <br /> |

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

### getAndUpdate

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

```
public final E getAndUpdate (int i, 
                UnaryOperator<E> 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` | `UnaryOperator`: a side-effect-free function <br /> |

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

### getOpaque

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

```
public final E 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 ||
|---|---|
| `E` | the value <br /> |

### getPlain

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

```
public final E 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 ||
|---|---|
| `E` | the 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, 
                E 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` | `E`: 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, 
                E 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` | `E`: 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, 
                E 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` | `E`: 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, 
                E 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` | `E`: 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, 
                E 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` | `E`: 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 E updateAndGet (int i, 
                UnaryOperator<E> 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` | `UnaryOperator`: a side-effect-free function <br /> |

| Returns ||
|---|---|
| `E` | 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, 
                E expectedValue, 
                E 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/AtomicReferenceArray#compareAndExchange(int,%20E,%20E)` and `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#compareAndSet(int,%20E,%20E)`). To avoid confusion over plain or volatile memory effects it is recommended that the method `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicReferenceArray#weakCompareAndSetPlain(int,%20E,%20E)` 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` | `E`: the expected value <br /> |
| `newValue` | `E`: the new value <br /> |

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

**See also:**

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

### weakCompareAndSetAcquire

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

```
public final boolean weakCompareAndSetAcquire (int i, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: 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, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: 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, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: 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, 
                E expectedValue, 
                E 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` | `E`: the expected value <br /> |
| `newValue` | `E`: the new value <br /> |

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