Open In App

AtomicReferenceArray get() method in Java with Examples

Last Updated : 03 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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 accepts the index i to get the value. Return value: This method returns current value at index i. Below programs illustrate the get() method: Program 1:
Output:
value at 0 = 12
value at 1 = 13
value at 2 = 14
value at 3 = 15
Program 2:
Output:
value at 0 = AMAN
value at 1 = AMAR
Reference: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReferenceArray.html#get(int)

Next Article

Similar Reads