确定ArrayList B是否为ArrayList a的子集
/*来自 nowjava - 时 代 Java*/ //package com.nowjava; import java.util.ArrayList; public class Main { /** * Determines if setB is a subSet of setA * * @param setA - the full set for the comparison * @param setB - the sub set to be tested * @return true if setB is a subSet of setA * @throws java.lang.IllegalArgumentException - * when one of setA or setB is null or empty */ public static boolean subSet(ArrayList<Integer> setA, ArrayList<Integer> setB) { if (null == setA || null == setB) { throw new IllegalArgumentException( "Arralist arguments cannot be null"); } if (setA.size() == 0 || setB.size() == 0) { throw new IllegalArgumentException( "Arraylist arguments cannot be empty"); } boolean isInList = true;/*from n o w j a v a . c o m*/ for (int i = 0; i < setA.size() && isInList; i++) { is