⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex28.java

📁 Thinking in Java第四版 课后习题的源码
💻 JAVA
字号:
// holding/Ex28.java
// TIJ4 Chapter Holding, Exercise 28, page 427
/* Fill a PriorityQueue (using offer()) with Double values created using 
* java.util.Random, then remove the elements using poll() and display them.
*/
import java.util.*;

public class Ex28 {
	public static void main(String[] args) {
		Random rand = new Random();
		PriorityQueue<Double> d = new PriorityQueue<Double>();
		for(int i = 0; i < 10; i++)
			d.offer(rand.nextDouble() * i);
		while(d.peek() != null)
			System.out.print(d.poll() + " ");
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -