[Java] 判断一个list是否包含于另一个list,如果没有,输出没包含的
ArrayList<String> actualList = ["1","2","3"] ArrayList<String> expectList = ["1","5","6"] containsList(actualList, expectList ) //Check the expectList in actualList static def containsList(ArrayList<String> actualList, ArrayList<String> expectList){ if(actualList.containsAll(expectList)){ assert true } else { ArrayList<String> actualListBackUp = actualList.clone() expectList.removeAll(actualList) assert false, "This data is not in list " + expectList } }
ArrayList<String> liasA = Arrays.asList(list);