最近我看到论坛有一个贴子“3秒搞定!~~ 一亿数据获取前1000个最大值”很热,我3条语句搞定:
        Random rand = new Random();
    PriorityQueue<Integer> P = new PriorityQueue<Integer>();
        for(int i = 0,num = rand.nextInt(); (i < 100 && P.add(num)) || (i < 100000000 && (P.peek() < num && P.add(num) && P.remove() != null || 1==1)); i++,num = rand.nextInt());
//System.out.println(P);