AtomicIntegerArray.getAndSet(int i, int newValue) has the following syntax.
public final int getAndSet(int i, int newValue)
In the following code shows how to use AtomicIntegerArray.getAndSet(int i, int newValue) method.
import java.util.concurrent.atomic.AtomicIntegerArray; /* w w w . jav a 2s . c om*/ public class Main { public static void main(String[] argv) throws Exception { AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[]{0,1,2,3}); atomicIntegerArray.getAndSet(0,10); System.out.println(atomicIntegerArray); } }
The code above generates the following result.