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