Java AtomicLong decrementAndGet() Method

The decrementAndGet() method of Java AtomicLong class subtracts 1 from the AtomicLong value and returns its value after the subtraction. 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 : 9

Example 3

Test it Now

Output:

Updated Value : -21




Latest Courses