I have a `Collection<T>`, named "col". Not important what contains the class T. When I iterate the collection, at each iteration I need to have the current element and the next. 

```
Iterator it = col.iterator();
while (it.hasNext()) {
  T line = (T) it.next();
  T nextLine = it.hasNext()? NEXT_LINE : null;
  // more Java code with line and nextLine
}

```

"NEXT\_LINE" is not a declared constant, but an invalid code. I need to replace it with a valid Java code that returns the next element from the collection, without incrementing again the iterator.

I found this link:
[Java iterator get next without incrementing](https://stackoverflow.com/questions/31080272/java-iterator-get-next-without-incrementing)

The weakness of this solution, in my case, is if the collection contains only 1 element, I have to do too many changes in my code. If there is a solution for my version, the case with 1 element is covered, because nextLine is null.

I can also convert the collection in an ArrayList, but I'll do this only when I consider there is not a better way:

```
ArrayList<T> list = new ArrayList<T>(col);
for (int i=0; i<list.size(); i++) {
  T line = list.get(i);
  T nextLine = i<list.size()-1 ? list.get(i+1) : null;
  // more Java code with line and nextLine
}

```