当前位置:才华君>社会工作>综合指导>

阿里巴巴笔试题-2个有序集合的交集

综合指导 阅读(5.76K)

(转载我使用的是TreeSet,因为题目要求是集合
  public static void test2() {
    TreeSet

阿里巴巴笔试题-2个有序集合的交集

a = new TreeSet();
    TreeSetb = new TreeSet();
    Random r = new Random();
    for (int i = 0; i < 30; i++) {
      (Int(30));
      (Int(30));
    }
    inAll(b);
    tln(a);
    tln(b);
    tln(a);
  }
其中的'retainAll是JDK自带的算法,我们看一下源代码
  public boolean retainAll(Collection