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 function accepts a single parameter i i.e the value of index to get.
Return value: The function returns the current value at index i.
Below programs illustrate the above method:
Program 1:
// Java program that demonstrates // the get() 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 to get int idx = 2; // Using get() to retrieve value at idx int val = arr.get(idx); // Displaying the value at idx System.out.println("Value at index " + idx + " is " + val); } } |
The array : [1, 2, 3, 4, 5] Value at index 2 is 3
Program 2:
// Java program that demonstrates // the get() function import java.util.concurrent.atomic.AtomicIntegerArray; public class GFG { public static void main(String args[]) { // Initializing an array int a[] = { 12, 22, 23, 24, 25 }; // Initializing an AtomicIntegerArray with array a AtomicIntegerArray arr = new AtomicIntegerArray(a); // Displaying the AtomicIntegerArray System.out.println("The array : " + arr); // Index to get int idx = 4; // Using get() to retrieve value at idx int val = arr.get(idx); // Displaying the value at idx System.out.println("Value at index " + idx + " is " + val); } } |
The array : [12, 22, 23, 24, 25] Value at index 4 is 25
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- AtomicIntegerArray set() method in Java with Examples
- AtomicIntegerArray getAndDecrement() method in Java with Examples
- AtomicIntegerArray incrementAndGet() method in Java with Examples
- AtomicIntegerArray length() method in Java with Examples
- AtomicIntegerArray getAndIncrement() method in Java with Examples
- AtomicIntegerArray addAndGet() method in Java with Examples
- AtomicIntegerArray compareAndSet() method in Java with Examples
- AtomicIntegerArray accumulateAndGet() method in Java with Examples
- AtomicIntegerArray decrementAndGet() method in Java with Examples
- AtomicIntegerArray updateAndGet() method in Java with Examples
- AtomicIntegerArray getAndSet() method in Java with Examples
- AtomicIntegerArray getAndUpdate() method in Java with Examples
- AtomicIntegerArray lazySet() method in Java with Examples
- AtomicIntegerArray toString() method in Java with Examples
- AtomicIntegerArray getAndAdd() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

