AtomicIntegerArray decrementAndGet() method in Java with Examples Last Updated : 01 Dec, 2020 Comments Improve Suggest changes Like Article Like Report The Java.util.concurrent.atomic.AtomicIntegerArray.decrementAndGet() is an inbuilt method in Java that atomically decrements by one the element at a given index. This method takes the index value and the value to be added as the parameters and returns the updated value at this index. Syntax: public final int decrementAndGet(int i) Parameters: The function accepts a single parameter i which is the index where decrement by one operation is performed. Return value: The function returns the updated value which is in Integer. Below programs illustrate the above method: Program 1: Java // Java program that demonstrates // the decrementAndGet() function import java.util.concurrent.atomic.AtomicIntegerArray; public class GFG { public static void main(String args[]) { // Initializing an array int a[] = { 1, 2, 3, 4, 5 }; // Initializing an AtomicIntegerArray with array a AtomicIntegerArray arr = new AtomicIntegerArray(a); // Displaying the AtomicIntegerArray System.out.println("The array : " + arr); // Index where operation is performed int idx = 3; // Updating the value at // idx applying decrementAndGet arr.decrementAndGet(idx); // Displaying the AtomicIntegerArray System.out.println("The array after update : " + arr); } } Output: The array : [1, 2, 3, 4, 5] The array after update : [1, 2, 3, 3, 5] Program 2: Java // Java program that demonstrates // the decrementAndGet() function import java.util.concurrent.atomic.AtomicIntegerArray; public class GFG { public static void main(String args[]) { // Initializing an array int a[] = { 1, 2, 3, 4, 5 }; // Initializing an AtomicIntegerArray with array a AtomicIntegerArray arr = new AtomicIntegerArray(a); // Displaying the AtomicIntegerArray System.out.println("The array : " + arr); // Index where operation is performed int idx = 0; // Updating the value at // idx applying decrementAndGet arr.decrementAndGet(idx); // Displaying the AtomicIntegerArray System.out.println("The array after update : " + arr); } } Output: The array : [1, 2, 3, 4, 5] The array after update : [0, 2, 3, 4, 5] Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicIntegerArray.html#decrementAndGet(int) Comment More infoAdvertise with us Next Article AtomicIntegerArray decrementAndGet() method in Java with Examples gopaldave Follow Improve Article Tags : Java Java-Functions Java-concurrent-package Java-AtomicIntegerArray Practice Tags : Java Similar Reads AtomicLongArray decrementAndGet() method in Java with Examples The Java.util.concurrent.atomic.AtomicLongArray.decrementAndGet() is an inbuilt method in Java that atomically decrements by one the element at a given index. This method takes the index value and the value to be added as the parameters and returns the updated value at this index. Syntax: public fin 2 min read AtomicIntegerArray compareAndSet() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.compareAndSet() is an inbuilt method in java that atomically sets the element at a position to the given updated value if the current value is equal to the expected value. This method takes the index value, the expected value and the update value as 5 min read AtomicLongArray compareAndSet() method in Java with Examples The Java.util.concurrent.atomic.AtomicLongArray.compareAndSet() is an inbuilt method in java that atomically sets the element at a position to the given updated value if the current value is equal to the expected value. This method takes the index value, the expected value and the update value as th 3 min read AtomicReferenceArray compareAndSet() method in Java with Examples The compareAndSet() method of a AtomicReferenceArray class is used to atomically sets the value of index i of AtomicReferenceArray to newValue, if the current value at index i of AtomicReferenceArray object is equal to the expectedValue.This method will return true if update is successful. Syntax: p 2 min read AtomicIntegerArray get() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.get() is an inbuilt method in java that gets the current value at any position of the AtomicIntegerArray. This method takes the index value as the parameter and returns the value at this index. Syntax: public final int get(int i) Parameters: The fun 2 min read AtomicIntegerArray set() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.set() is an inbuilt method in Java that sets a given value at any position of the AtomicIntegerArray. This method takes the index value of the AtomicIntegerArray as parameter and updates the value at that index. This method does not return any value 2 min read AtomicIntegerArray getAndSet() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.getAndSet() is an inbuilt method in Java that atomically sets a given value at any given position of the AtomicIntegerArray. The method takes the index value of the AtomicIntegerArray and the value to set as the parameters. It returns the value at t 3 min read AtomicIntegerArray length() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.length() is an inbuilt method in Java that returns the length of the AtomicIntegerArray. This method does not accepts any parameter and returns the length of the AtomicIntegerArray which is of type int. Syntax: public final int length() Parameters: 2 min read AtomicIntegerArray lazySet() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.lazySet() is an inbuilt method in Java that eventually sets a given value at any given index of an AtomicIntegerArray. The method takes the index value of the AtomicIntegerArray and the value to set as the parameters and updates the previous value w 2 min read AtomicInteger doubleValue() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.doubleValue() is an inbuilt method in java which returns the current value of the AtomicInteger as a Double data-type after performing primitive conversion. Syntax: public double doubleValue() Parameters: The function does not accepts any parameter. Retu 1 min read Like