title: What is the most elegant way to run a lambda for each element of a Java 8 stream and simultaneously count how many elements were processed?
body: <p>What is the most elegant way to run a lambda for each element of a Java 8 stream and simultaneously count how many items were processed, assuming I want to process the stream only once and not mutate a variable outside the lambda?</p>