Given:
import java.util.concurrent.atomic.AtomicInteger;
public class AtomicCounter {
private AtomicInteger c = new AtomicInteger(0);
public void increment() {
// insert code here
}
}
Which line of code, inserted inside the increment () method, will increment the value of c?
A.
c.addAndGet();
B.
c++;
C.
c = c+1;
D.
c.getAndIncrement ();
Explanation:
getAndIncrement
public final int getAndIncrement()
Atomically increment by one the current value.
Reference:java.util.concurrent.atomic
D
D