AtomicInteger.incrementAndGet() vs. AtomicInteger.getAndIncrement()

Since no answer to the actual question has been given, here’s my personal opinion based on the other answers (thanks, upvoted) and Java convention:

incrementAndGet()

is better, because method names should start with the verb describing the action, and intended action here is to increment only.

Starting with verb is the common Java convention, also described by official docs:

“Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.”

Leave a Comment

tech