您的位置:首页 > 职场人生

面试题:以下程序的输出结果是什么?

2015-02-25 09:42 267 查看
package com.njue.mis;

import java.util.*;

public class Test {

public static void main(String[] args){

Queue<Integer> queue = new PriorityQueue<Integer>(10,

new Comparator<Integer>(){

public int compare(Integer i,Integer j){

int result = i%2-j%2;

if(result == 0)

result = i -j;

return result;

}

});

for(int i = 0; i<10; i++)

{

queue.offer(i);

}

for(int i = 0; i<10; i++)

{

System.out.println(queue.poll());

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐