Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.atomic.AtomicInteger; public class AtomicIntegerAddAndGetExp2 { public static void main(String[] args) { System.out.println("when initial value is 100: "+addAndGet()); } public static int addAndGet() { AtomicInteger number = new AtomicInteger(100); int number1 = number.addAndGet(2); return (number1); } }
Output