Вот рабочий пример, если интересно.
package test;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
public class ListTest {
public static void main(String[] args) {
LinkedList<Integer> list = new LinkedList<Integer>();
list.add(1);
list.add(2);
list.add(3);
Iterator<Integer> i = list.iterator();
while (i.hasNext()) {
Iterator<Integer> j = copyIterator(list, i);
Integer x = i.next();
if (j != null) {
while (j.hasNext()) {
Integer y = j.next();
System.out.println(x + " " + y);
}
}
}
}
private static <T> Iterator<T> copyIterator(LinkedList<T> list, Iterator<T> i) {
try {
Class<?> iteratorClass = i.getClass();
Constructor<?> constructor = iteratorClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
Object result = constructor.newInstance(list, list.size());
for (Field field : iteratorClass.getDeclaredFields()) {
if (!Modifier.isFinal(field.getModifiers())) {
field.setAccessible(true);
field.set(result, field.get(i));
}
}
@SuppressWarnings("unchecked") Iterator<T> resultIterator = (Iterator<T>) result;
return resultIterator;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}