We have a list of elements and have a very simplistic collision detection where we check every object against every other object.

The check is commutative, so to avoid repeating it twice, we would do this in C++:

for (list<Object>::iterator it0 = list.begin(); it0 != list.end(); ++it0)
{
    for (list<Object>::iterator it1 = it0; it1 != list.end(); ++it1)
    {
        Test(*it0, *it1);
    }
}

The key bit here is the copy

it1 = it0

How would you write this in Java?

Edit
Report