AtomicBoolean toString() method in Java with Examples
The java.util.concurrent.atomic.AtomicBoolean.toString() is an inbuilt method in java that returns the string representation of the current value which is been stored in the boolean.
Syntax:
public String toString()
Parameters: The function does not accepts any parameter.
Return Value: The function returns the string representation of the current value.
Below programs illustrate the above function:
Program 1:
// Java program that demonstrates // the toString() function import java.util.concurrent.atomic.AtomicBoolean; public class GFG { public static void main(String args[]) { // Initially value as true AtomicBoolean val = new AtomicBoolean(true); String s = val.toString(); // Prints the string value System.out.println("String value: " + s); } } |
String value: true
Program 2:
// Java program that demonstrates // the toString() function import java.util.concurrent.atomic.AtomicBoolean; public class GFG { public static void main(String args[]) { // Initially value as false AtomicBoolean val = new AtomicBoolean(false); String s = val.toString(); // Prints the string value System.out.println("String value: " + s); } } |
String value: false
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicBoolean.html#toString–
Recommended Posts:
- AtomicBoolean get() method in Java with Examples
- AtomicBoolean set() method in Java with Examples
- AtomicBoolean getAndSet() method in Java with Examples
- AtomicBoolean compareAndSet() method in Java with Examples
- AtomicBoolean lazySet() method in Java with Examples
- ChronoZonedDateTime toString() method in Java with Examples
- AtomicInteger toString() method in Java with examples
- LinkedTransferQueue toString() method in Java with Examples
- ZoneId toString() method in Java with Examples
- LongAccumulator toString() method in Java with Examples
- Boolean toString() method in Java with examples
- Byte toString() method in Java with examples
- Throwable toString() method in Java with Examples
- LocalDate toString() method in Java with Examples
- Calendar toString() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



