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