ex29.java

来自「java编程思想第四版课后习题答案Annotated+Solution+Guid」· Java 代码 · 共 22 行

JAVA
22
字号
// holding/Ex29.java
// TIJ4 Chapter Holding, Exercise 29, 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.*;

class Simple extends Object {}

public class Ex29 {
	public static void main(String[] args) {		
		PriorityQueue<Simple> s = new PriorityQueue<Simple>();
		// OK to add one Simple:
		s.offer(new Simple());
		// but no more allowed; get runtime exception: 
		// Simple cannot be cast to Comparable:
		s.offer(new Simple());
	}
}


⌨️ 快捷键说明

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