Overview

Most occasions in logic where it is necessary to keep a counter, a simple integer value is sufficient.

int i=0;
while (...) {
    ...
    ++i;
    ...
}

There are some cases where this is not sufficient because an object must be used. For cases like this, we created Counter. The primary operations of Counter are increment/decrement.

The above logic can be equivalently replaced with

Counter i = new Counter();
while (...) {
    ...
    i.increment;
    ...
}

More usefully, it can be used in a context where an object is required.

Map<String,Counter> map;
...
map.get("key1").increment();

Project Overview