Here you can find the source of compareList(List
Parameter | Description |
---|---|
T | The type of items in the list |
listA | List 1 |
listB | List 2 |
public static <T> boolean compareList(List<T> listA, List<T> listB)
//package com.java2s; /*/*from w ww. j a v a 2s . c o m*/ * Copyright 2008-2013 LinkedIn, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ import java.util.List; public class Main { /** * Compares two lists * * @param <T> The type of items in the list * @param listA List 1 * @param listB List 2 * @return Returns a boolean comparing the lists */ public static <T> boolean compareList(List<T> listA, List<T> listB) { // Both are null. if (listA == null && listB == null) return true; // At least one of them is null. if (listA == null || listB == null) return false; // If the size is different. if (listA.size() != listB.size()) return false; // Since size is same, containsAll will be true only if same return listA.containsAll(listB); } }