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

📄 ex25(3).java

📁 JAVA编程思想第四版英文原版习题答案. pdf原版的
💻 JAVA
字号:
// generics/Ex25.java
// TIJ4 Chapter Generics, Exercise 25, page 677
/* Create two interfaces and a class that implements both. Create two
* generic methods, one whose argument parameter is bounded by the first
* interface and one whose argument parameter is bounded by the second
* interface. Create an instance of the class that implements both 
* interfaces, and show that it can be used with both generic methods.
*/

interface A {}

interface B {} 

class C implements A, B {
	public String toString() { return "C"; }
}

public class Ex25 {
	<T extends A> void a(T t) { System.out.println("a(" + t + ")"); }
	<T extends B> void b(T t) { System.out.println("b(" + t + ")"); }
	public static void main(String[] args) {
		C c = new C();
		Ex25 ex = new Ex25();
		ex.a(c);
		ex.b(c);
	}
}

⌨️ 快捷键说明

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