The Java.util.concurrent.atomic.AtomicLong.addandget() is an inbuilt method in java which adds the value which is passed in the parameter of the function to the previous value and returns the new updated value which is of data-type long.
public final long addAndGet(long val)
Parameters: The function accepts a single mandatory parameter val which specifies the value to be added.
Return value: The function returns the value after addition is done.
Below programs illustrate the above method:
Updated value: 6
Previous value: 18 Updated value: 24
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.