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