Android examples for java.util:List Element
compare two list isEquals(null, null) = true;
//package com.java2s; import java.util.ArrayList; public class Main { /**//from w w w.ja v a2s.c om * compare two list * * <pre> * isEquals(null, null) = true; * isEquals(new ArrayList<String>(), null) = false; * isEquals(null, new ArrayList<String>()) = false; * isEquals(new ArrayList<String>(), new ArrayList<String>()) = true; * </pre> * * @param <V> * @param actual * @param expected * @return */ public static <V> boolean isEquals(ArrayList<V> actual, ArrayList<V> expected) { if (actual == null) { return expected == null; } if (expected == null) { return false; } if (actual.size() != expected.size()) { return false; } for (int i = 0; i < actual.size(); i++) { if (actual.get(i) == expected.get(i) || (actual.get(i) == null ? expected.get(i) == null : actual.get(i).equals(expected.get(i)))) { return false; } } return true; } }