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

# AtomicIntegerArray


`
public


class
AtomicIntegerArray
`


`

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.AtomicIntegerArray |

<br />

*** ** * ** ***

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

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

### AtomicIntegerArray

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

```
public AtomicIntegerArray (int length)
```

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

<br />

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

### AtomicIntegerArray

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

```
public AtomicIntegerArray (int[] array)
```

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

<br />

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

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

### addAndGet

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

```
public final int addAndGet (int i, 
                int 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` | `int`: the value to add <br /> |

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

### compareAndExchange

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

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

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

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

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

### get

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

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

### getAcquire

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

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

### getAndAccumulate

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

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

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

### getAndAdd

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

```
public final int getAndAdd (int i, 
                int 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` | `int`: the value to add <br /> |

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

### getAndDecrement

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

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

### getAndIncrement

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

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

### getAndSet

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

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

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

### getAndUpdate

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

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

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

### getOpaque

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

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

### getPlain

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

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

### incrementAndGet

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

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

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

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

**See also:**

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

### weakCompareAndSetAcquire

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

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

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