I was trying to achieve something like this using lambdas. However, "i" has to be final.
int i = 1;
for (Object obj : list) {
if (something) {
i++;
}
}
edit:
But what if I wanted to add, let's say, a value that is different from object to object?
int i = 1;
for (Object obj : list) {
if (something) {
otherMethod(i);
i += obj.getValue();
}
}