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