Java API Tutorial - Java AtomicLong.intValue()








Syntax

AtomicLong.intValue() has the following syntax.

public int intValue()

Example

In the following code shows how to use AtomicLong.intValue() method.

import java.util.concurrent.atomic.AtomicLong;
/*from   ww w  .j  a  va 2s  . com*/
public class Main {
  public static void main(String[] argv) {
    AtomicLong nextId = new AtomicLong();

    System.out.println(nextId.getAndIncrement());
    System.out.println(nextId.intValue());
  }
}

The code above generates the following result.