AtomicInteger intValue() method in Java with examples
The java.util.concurrent.atomic.AtomicInteger.intValue() is an inbuilt method in java that returns the value which is currently stored in the object which is of data-type int.
Syntax:
public int intValue()
Parameters: The function does not accepts a single parameter.
Return value: The function returns the current value.
Program below demonstrates the function:
Program 1:
// Java program that demonstrates // the intValue() function import java.util.concurrent.atomic.AtomicInteger; public class GFG { public static void main(String args[]) { // Initially value as 0 AtomicInteger val = new AtomicInteger( 0 ); int res = val.intValue(); // Prints the updated value System.out.println( "Current value: " + res); } } |
Current value: 0
Program 2:
// Java program that demonstrates // the intValue() function import java.util.concurrent.atomic.AtomicInteger; public class GFG { public static void main(String args[]) { // Initially value as 18 AtomicInteger val = new AtomicInteger( 18 ); int res = val.intValue(); // Prints the updated value System.out.println( "Current value: " + res); } } |
Current value: 18
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicInteger.html#intValue–
Recommended Posts:
- AtomicInteger set() method in Java with examples
- AtomicInteger get() method in Java with examples
- AtomicLong intValue() method in Java with examples
- AtomicInteger incrementAndGet() method in Java with examples
- AtomicInteger lazySet() method in Java with examples
- Level intValue() method in Java with Examples
- AtomicInteger weakCompareAndSet() method in Java with examples
- AtomicInteger longValue() method in Java with examples
- AtomicInteger getAndDecrement() method in Java with examples
- AtomicInteger floatValue() method in Java with examples
- AtomicInteger addAndGet() method in Java with examples
- AtomicInteger compareAndSet() method in Java with examples
- AtomicInteger decrementAndGet() method in Java with examples
- Byte intValue() method in Java with examples
- AtomicInteger doubleValue() 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.