自己编程序,把两个collection里面的元素取出来比较,不过这样有点慢!为什么不在sql语句里面做这样的操作呢?这样速度要快得多!

解决方案 »

  1.   

    //取并集
    public Collection getCombination(Collection colA, Collection colB){
      HashSet hs = new HashSet(colA);
      hs.addAll(colB);
      return hs;
    }//取交集
    public Collection getIntersection (Collection colA, Collection colB){
      HashSet hs = new HashSet(colA);
      hs.retainAll(colB);
      return hs;
    }
      

  2.   

    我试了,并集可以,但是交集每次得到的都是null,是不是有问题啊。
      

  3.   

    没问题的
    bsd(小红帽菜鸟) 
    可以实现的