Here you can find the source of listEquals(List
public static <T> boolean listEquals(List<T> left, List<T> right)
//package com.java2s; //License from project: Apache License import java.util.List; import java.util.ListIterator; public class Main { public static <T> boolean listEquals(List<T> left, List<T> right) { if (left == right) return true; ListIterator<T> leftIterator = left.listIterator(); ListIterator<T> rightIterator = right.listIterator(); while (leftIterator.hasNext() && rightIterator.hasNext()) { T leftElement = leftIterator.next(); T rightElement = rightIterator.next(); if (!(leftElement == null ? rightElement == null : leftElement.equals(rightElement))) return false; }/* w w w . j a v a 2s .c om*/ return !(leftIterator.hasNext() || rightIterator.hasNext()); } }