Java AtomicLong incrementAndGet() Method

The incrementAndGet() method of Java AtomicLong class increments current value by 1 and return updated value. This method is equivalent to AtomicLong addAndGet(1) method.

Syntax

Returns

the updated value

Example 1

Test it Now

Output:

Updated Value : 1

Example 2

Test it Now

Output:

Updated Value : 11

Example 3

Test it Now

Output:

Updated Value : -19




Latest Courses