Here you can find the source of isEqual(List extends Object> list1, List extends Object> list2)
Parameter | Description |
---|---|
list1 | The first list. |
list2 | The second list. |
public static boolean isEqual(List<? extends Object> list1, List<? extends Object> list2)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.List; public class Main { /**/* w ww . j a v a 2 s. c o m*/ * Checks if the given list are equals, this means that they contain the * same elements. * * @param list1 The first list. * @param list2 The second list. * * @return True, if both lists contain the same elements, false otherwise. */ public static boolean isEqual(List<? extends Object> list1, List<? extends Object> list2) { /* * TODO check if this is actual not the default implementation of java for equals */ if (list1.size() != list2.size()) { return false; } for (Iterator<? extends Object> it = list1.iterator(); it.hasNext();) { Object obj = it.next(); if (!list2.contains(obj)) { return false; } } return true; } }