AtomicReferenceArray toString() method in Java with Examples Last Updated : 03 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The toString() method of a AtomicReferenceArray class is used to return the String representation of the current values of array.This method is used to represent the contents of AtomicReferenceArray as string Syntax: public String toString() Parameters: This method accepts nothing. Return value: This method returns the String representation of the current values of array. Below programs illustrate the toString() method: Program 1: Java // Java program to demonstrate // toString() method import java.util.concurrent.atomic.*; public class GFG { public static void main(String[] args) { // create an atomic reference object. AtomicReferenceArray<Integer> ref = new AtomicReferenceArray<Integer>(5); // set some value ref.set(0, 234); ref.set(1, 134); ref.set(2, 325); // print the toString() return String toString = ref.toString(); System.out.println( "String representation of" + " AtomicReferenceArray:\n" + toString); } } Output: String representation of AtomicReferenceArray: [234, 134, 325, null, null] Program 2: Java // Java program to demonstrate // toString() method import java.util.concurrent.atomic.*; public class GFG { public static void main(String[] args) { // create a array of Strings String[] names = { "AMAN", "AMAR", "SURAJ" }; // create an atomic reference object. AtomicReferenceArray<String> ref = new AtomicReferenceArray<String>(names); // print the toString() return String toString = ref.toString(); System.out.println( "String representation of" + " AtomicReferenceArray:\n" + toString); } } Output: String representation of AtomicReferenceArray: [AMAN, AMAR, SURAJ] References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReferenceArray.html#toString() Comment More infoAdvertise with us Next Article AtomicReferenceArray set() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-util-concurrent-atomic package Java-AtomicReferenceArray Practice Tags : Java Similar Reads AtomicReference toString() method in Java with Examples The toString() method of a AtomicReference class is used to return the String representation of the current value of AtomicReference object. Syntax: public String toString() Parameters: This method accepts nothing. Return value: This method returns the String representation of the current value. Bel 1 min read AtomicReferenceArray set() method in Java with Examples The set() method of a AtomicReferenceArray class is used to set the value of the element at index i to newValue. Both index i and newValue are passed as parameters to the method. This method set the value with memory semantics of reading as if the variable was declared volatile type of variable. Syn 2 min read AtomicIntegerArray toString() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.toString() is an inbuilt method in Java that returns a string that textually represents the current values of the AtomicIntegerArray. The resulting string is a concise and informative representation that is easy for a person to read. It is used to e 2 min read AtomicLongArray toString() method in Java with Examples The Java.util.concurrent.atomic.AtomicLongArray.toString() is an inbuilt method in Java that returns a string that textually represents the current values of the AtomicLongArray. The resulting string is a concise and informative representation that is easy for a person to read. It is used to easily 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 AtomicReferenceArray updateAndGet() method in Java with Examples The updateAndGet() method of a AtomicReferenceArray class is used to atomically updates which updates the current value of the AtomicReferenceArray by applying the specified updateFunction operation on the current value. It takes an object of updateFunction interface as its parameter and applies the 2 min read Like