So, now it looks correct, but I still don't see the reason of having this `k` variable. For what it is?
And I would prefer having a `for` loop like (equivalent to your `while` loop but much clear):

```java
for (int j = rowPointers[i]; j < rowPointers[i + 1]; j++) {
  procedure.apply(i, columnIndices[j], values[j]);
}
```