日期:2014-05-20 浏览次数:20802 次
public class Test { public List left(Integer[] a,Integer[] b){//c1是相对大的集合,C2是小集合 List<Integer> c1 = new ArrayList<Integer>(), c2= new ArrayList<Integer>(), list = new ArrayList<Integer>(); c1.addAll(Arrays.asList(a)); c2.addAll(Arrays.asList(b)); for(int i=0;i<c1.size();i++){ if(!c2.contains(c1.get(i))){ list.add(c1.get(i)); } } return list; } public static void main(String[] args) { Integer[] c ={1,2,3,4,56,6}; Integer[] d = {2,3,4}; List list = new Test().left(c, d); for(Object o:list){ System.out.println((Integer)o); } } }