Java AtomicInteger .getAndIncrement ()
Syntax
AtomicInteger.getAndIncrement() has the following syntax.
public final int getAndIncrement()
Example
In the following code shows how to use AtomicInteger.getAndIncrement() method.
/*w w w.j a v a 2 s.c o m*/
import java.util.concurrent.atomic.AtomicInteger;
public class Main {
public static void main(String[] argv) throws Exception {
AtomicInteger atomicInteger = new AtomicInteger();
System.out.println(atomicInteger.getAndIncrement());
}
}
The code above generates the following result.