等于迭代器
//package com.nowjava; import java.util.ArrayList; //nowjava.com 提供 import java.util.Iterator; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static <T> boolean equalsIters(Iterator<T> it1, Iterator<T> it2) { List list1 = new ArrayList(); List list2 = new ArrayList(); while (it1.hasNext()) { list1.add(it1.next()); }/** 来自 N o w J a v a . c o m**/ while (it2.hasNext()) { list2.add(it2.next()); } return equalsLists(list1, list2); } public static <T> boolean equalsLists(List list1, List list2) { if (list1.size() != list2.size()) { return false; } for (int i = 0; i < list1.size(); ++i) { if (!equals(list1.get(i), list2.get(i))) { return false; } } return true; }