Java API Tutorial - Java AtomicLong.toString()








Syntax

AtomicLong.toString() has the following syntax.

public String toString()

Example

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

/*ww  w  .  j a  va2  s  .com*/
import java.util.concurrent.atomic.AtomicLong;

public class Main {
  public static void main(String[] argv) {
    AtomicLong nextId = new AtomicLong();

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

The code above generates the following result.