Iterable相等
//package com.nowjava;/** from 时 代 J a v a 公 众 号 - nowjava.com**/ import java.util.Iterator; public class Main { public static <T> boolean equal(Iterable<T> first, Iterable<T> second) { return equal(first.iterator(), second.iterator()); } public static <T> boolean equal(Iterator<T> first, Iterator<T> second) { while (first.hasNext() && second.hasNext()) { T message = first.next(); T otherMessage = second.next(); /* Element? ??? ? */ /** 来自 时代Java公众号**/ if (!(message == null ? otherMessage == null : message .equals(otherMessage))) {