Java API Tutorial - Java AtomicInteger .decrementAndGet ()








Syntax

AtomicInteger.decrementAndGet() has the following syntax.

public final int decrementAndGet()

Example

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

/*  www. j a  v  a  2s .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.decrementAndGet());
  }
}

The code above generates the following result.