Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.atomic.AtomicLong; public class AtomicLongGetAndSetExample3 { public static void main (String [] args) { AtomicLong atomiclong = new AtomicLong(-10); //Returns the previous value Long result = atomiclong.getAndSet(20); //Prints the previous value System.out.println("Previous Value : " + result); //Sets and prints the New Value System.out.println("New Value : " + atomiclong); } }
Output