Java AtomicInteger .incrementAndGet ()

Syntax

AtomicInteger.incrementAndGet() has the following syntax.

public final int incrementAndGet()

Example

In the following code shows how to use AtomicInteger.incrementAndGet() method.


import java.util.concurrent.atomic.AtomicInteger;
/*from  w  w w  . j  ava 2  s. c o m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    AtomicInteger atomicInteger = new AtomicInteger();
    
    System.out.println(atomicInteger.incrementAndGet());
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.util.concurrent.atomic »




AtomicBoolean
AtomicInteger
AtomicIntegerArray
AtomicLong
AtomicLongArray