Java AtomicInteger set() method

20 Mar 2025 | 1 min read

The set() method of Java AtomicInteger sets the atomicinteger value to the given value.

Syntax

Parameters

It is the new value.

Return

It does not return any value.

Example 1

Output:

 the new value is:100 

Example 2

Output:

 the new value is:1 

Example 3

Output:

 the new value is:10 

Example 4

Output:

 the new value is:0 

Example 5

Output:

 the new value is:-10