AtomicReferenceArray length() method in Java with Examples Last Updated : 03 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The length() method of a AtomicReferenceArray class is used to return the length of this AtomicReferenceArray. Syntax: public final int length() Parameters: This method accepts nothing. Return value: This method returns the integer representing length of this AtomicReferenceArray. Below programs illustrate the length() method: Program 1: Java // Java program to demonstrate // AtomicReferenceArray.length() 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); // print the length int length = ref.length(); System.out.println( "length of AtomicReferenceArray = " + length); } } Output: length of AtomicReferenceArray = 5 Program 2: Java // Java program to demonstrate // AtomicReferenceArray.length() 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 length int length = ref.length(); System.out.println( "length of AtomicReferenceArray = " + length); } } Output: length of AtomicReferenceArray = 3 References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReferenceArray.html#length() Comment More infoAdvertise with us Next Article AtomicReferenceArray length() 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 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 AtomicLongArray length() method in Java with Examples The Java.util.concurrent.atomic.AtomicLongArray.length() is an inbuilt method in Java that returns the length of the AtomicLongArray. This method does not accepts any parameter and returns the length of the AtomicLongArray which is of type int. Syntax: public final int length() Parameters: The funct 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 toString() method in Java with Examples 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: Thi 2 min read AtomicReferenceArray getPlain() method in Java with Examples The getPlain() 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 was declared non-volatile.Syntax: public final E getPlain(int i) Parameters: This method accepts the in 2 min read Like