Skip to content
Advertisement

Java – Iterating over every two elements in a list

What’s the best way to iterate over a list while processing 2 elements at the same time?

Example:

JavaScript

Results in:

JavaScript

I would like to achieve:

JavaScript

Advertisement

Answer

Just increase i by 2:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement