AtomicLongArray get() method in Java with Examples Last Updated : 05 Feb, 2019 Comments Improve Suggest changes Like Article Like Report The Java.util.concurrent.atomic.AtomicLongArray.get() is an inbuilt method in java that gets the current value at any position of the AtomicLongArray. This method takes the index value as the parameter and returns the value at this index. Syntax: public final long 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 // Java program that demonstrates // the get() function import java.util.concurrent.atomic.AtomicLongArray; public class GFG { public static void main(String args[]) { // Initializing an array long a[] = { 1, 2, 3, 4, 5 }; // Initializing an AtomicLongArray with array a AtomicLongArray arr = new AtomicLongArray(a); // Displaying the AtomicLongArray System.out.println("The array : " + arr); // Index to get int idx = 2; // Using get() to retrieve value at idx long val = arr.get(idx); // Displaying the value at idx System.out.println("Value at index " + idx + " is " + val); } } Output: The array : [1, 2, 3, 4, 5] Value at index 2 is 3 Program 2: Java // Java program that demonstrates // the get() function import java.util.concurrent.atomic.AtomicLongArray; public class GFG { public static void main(String args[]) { // Initializing an array long a[] = { 12, 22, 23, 24, 25 }; // Initializing an AtomicLongArray with array a AtomicLongArray arr = new AtomicLongArray(a); // Displaying the AtomicLongArray System.out.println("The array : " + arr); // Index to get int idx = 4; // Using get() to retrieve value at idx long val = arr.get(idx); // Displaying the value at idx System.out.println("Value at index " + idx + " is " + val); } } Output: The array : [12, 22, 23, 24, 25] Value at index 4 is 25 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLongArray.html#get-int- Comment More infoAdvertise with us Next Article AtomicLongArray get() method in Java with Examples rupesh_rao Follow Improve Article Tags : Java Java - util package Java-Functions Java-AtomicLongArray Practice Tags : Java Similar Reads 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 AtomicReferenceArray get() method in Java with Examples The get() method of a AtomicReferenceArray class is used to return the value of the element at index i for this AtomicReferenceArray object with memory semantics of reading as if the variable of index was declared volatile type of variable. Syntax: public final E get(int i) Parameters: This method a 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 Dictionary get() Method in Java with Examples The get() method of Dictionary class is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns NULL when the dictionary contains no such mapping for the key. Syntax: DICTIONARY.get(Object key_element) Parameters: The method takes one parameter key_eleme 2 min read AtomicIntegerArray getAndAdd() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.getAndAdd() is an inbuilt method in Java that atomically adds the given value to the element at an index of the AtomicIntegerArray. This method takes the index value of the AtomicIntegerArray and the value to be added as the parameters and returns t 3 min read Like