Use IntStream instead of for loop with counter.