AtomicInteger get() method in Java with examples Last Updated : 31 Jan, 2019 Comments Improve Suggest changes Like Article Like Report The java.util.concurrent.atomic.AtomicInteger.get() is an inbuilt method in java which returns the current value which is of date-type int. Syntax: public final int get() Parameters: The function does not accepts any parameter. Return value: The function returns the current value Program below demonstrates the function: Program 1: Java // Java Program to demonstrates // the get() 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); val.addAndGet(7); // Prints the updated value System.out.println("Previous value: " + val); // Gets the current value int res = val.get(); System.out.println("current value: " + res); } } Output: Previous value: 7 current value: 7 Program 2: Java // Java Program to demonstrates // the get() 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); val.addAndGet(7); // Prints the updated value System.out.println("Previous value: " + val); // Gets the current value int res = val.get(); System.out.println("current value: " + res); } } Output: Previous value: 25 current value: 25 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicInteger.html#get-- Comment More infoAdvertise with us Next Article AtomicInteger get() method in Java with examples gopaldave Follow Improve Article Tags : Java Java - util package Java-Functions Java-AtomicInteger Practice Tags : Java Similar Reads AtomicIntegerArray get() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.get() is an inbuilt method in java that gets the current value at any position of the AtomicIntegerArray. This method takes the index value as the parameter and returns the value at this index. Syntax: public final int get(int i) Parameters: The fun 2 min read AtomicInteger getAndSet() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.getAndSet() is an inbuilt method in java that sets the given value to the value passed in the parameter and returns the value before updation which is of data-type int. Syntax: public final int getAndSet(int val) Parameters: The function accepts a single 2 min read AtomicInteger getAndAdd() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.getAndAdd() is an inbuilt method in java that adds the given value to the current value and returns the value before updation which is of data-type int. Syntax: public final int getAndAdd(int val) Parameters: The function accepts a single mandatory param 2 min read AtomicLong get() method in Java with examples The Java.util.concurrent.atomic.AtomicLong.get() is an inbuilt method in java which returns the current value which is of date-type long. Syntax: public final long get() Parameters: The function does not accepts any parameter. Return value: The function returns the current value Below programs illus 1 min read AtomicInteger set() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.set() is an inbuilt method in java that updates the previous value and sets it to a new value which is passed in the parameter. Syntax: public final void set(int newVal) Parameters: The function accepts a single mandatory parameter newVal which is to be 1 min read AtomicReference get() method in Java with Examples The get() method of a AtomicReference class is used to return the value of this AtomicReference object with memory semantics of reading as if the variable was declared volatile type of variable. Syntax: public final V get() Parameters: This method accepts nothing. Return value: This method returns c 1 min read AtomicLongArray get() method in Java with Examples The Java.util.concurrent.atomic.AtomicLongArray.get() is an inbuilt method in java that gets the current value at any position of the AtomicLongArray. This method takes the index value as the parameter and returns the value at this index. Syntax: public final long get(int i) Parameters: The function 2 min read 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 retur 1 min read AtomicInteger floatValue() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.floatValue() is an inbuilt method in java which returns the current value of the AtomicInteger as a Float data-type after performing primitive conversion. Syntax: public float floatValue() Parameters: The function does not accepts any parameter. Return v 1 min read AtomicIntegerArray getAndSet() method in Java with Examples The Java.util.concurrent.atomic.AtomicIntegerArray.getAndSet() is an inbuilt method in Java that atomically sets a given value at any given position of the AtomicIntegerArray. The method takes the index value of the AtomicIntegerArray and the value to set as the parameters. It returns the value at t 3 min read Like