AtomicReference toString() method in Java with Examples
Last Updated :
27 Dec, 2019
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.
Below programs illustrate the toString() method:
Program 1:
import java.util.concurrent.atomic.AtomicReference;
public class GFG {
public static void main(String[] args)
{
AtomicReference<Double> ref
= new AtomicReference<Double>();
ref.set( 1234.00 );
System.out.println( "Value = "
+ ref.toString());
}
}
|
Program 2:
import java.util.concurrent.atomic.AtomicReference;
public class GFG {
public static void main(String[] args)
{
AtomicReference<String> ref
= new AtomicReference<String>();
ref.set( "GFG" );
System.out.println( "Value = "
+ ref.toString());
}
}
|
References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReference.html#toString()
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...