java 判断一个List是否是另一个List的子集
/** 判断List2是否属于list1的子集 * @param list1 * @param list2 * @return */ public static <E> boolean isSubList(List<E> parent, List<E> children) { List<E> parent_1 = new ArrayList<>(); parent_1.addAll(parent); List<E> children_1 = new ArrayList<>(); children_1.addAll(children); int differ = parent_1.size() - children_1.size(); parent_1.removeAll(children_1); if (differ > 0 && differ == parent_1.size()) { return true; } else { return false; } }