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.
public final void set(int newVal)
Parameters: The function accepts a single mandatory parameter newVal which is to be updated.
Return value: The function does not returns anything.
Program below demonstrates the function:
Previous value: 0 Current value: 10
Previous value: 18 Current value: 200
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.