Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.atomic.AtomicInteger; public class AtomicIntegerGetAndSetExp3 { public static void main(String[] args) { AtomicInteger number = new AtomicInteger(100); int number1 = number.getAndSet(200); System.out.println("the updated number: "+number); System.out.println("the old number: "+ number1); } }
Output