Question: I'm trying to write a very simple piece of code and can't figure out an elegant solution to do it:

```
int count = 0;
jdbcTemplate.query(readQuery, new RowCallbackHandler() {
         @Override
         public void processRow(ResultSet rs) throws SQLException {
            realProcessRow(rs);
            count++;
         }
      });

```

This obviously doesn't compile. The 2 solutions that I'm aware of both stink:
I don't want to make count a class field because it's really a local variable that I just need for logging purposes.
I don't want to make count an array because it is plain ugly.

This is just silly, there got to be a reasonable way to do it?

Answer: 
A third possibility is to use a final-mutable-int-object, for example:

```
final AtomicInteger count = new AtomicInteger(0);
....
count.incrementAndGet();

```

Apache Commons also have a `MutableInteger` I believe, but I have not used it.
I typically make count a class field but add a comment that it is only a field because it is used by an inner closure, Runnable etc...