Java笔记之泛型接口
2011-11-25 11:32
267 查看
interface Demo<T> { // 定义泛型接口 public void print(T param); // 定义抽象方法,此方法输出参数 } // 实现泛型接口,方法一: class Imple1<T> implements Demo<T> { public void print(T param) { System.out.println("param = " + param); } } //实现泛型接口,方法二: class Imple2 implements Demo<Imple2> { public void print(Imple2 param) { System.out.println("param = " + param); } } public class GenericsDemo { public static void main(String[] args) { // 对以上程序进行测试 Imple1<String> demo = new Imple1<String>(); demo.print("Hello, Wrold!"); Imple2 im = new Imple2(); im.print(new Imple2()); } }
相关文章推荐
- JAVA学习笔记之泛型接口
- Java学习笔记之泛型(四):泛型接口
- Java基础学习笔记(九)Comparable接口、Map接口、泛型
- 【JAVA笔记——道】泛型接口设计(未完成)
- Java基础学习笔记(九)Comparable接口、Map接口、泛型
- Java笔记 – 泛型 泛型方法 泛型接口 擦除 边界 通配符
- Android(java)学习笔记91:泛型接口的概述和使用
- java笔记--什么是接口回调,怎么用
- JAVA基础再回首(十六)——泛型的概述、使用、泛型类、泛型方法、泛型接口、泛型高级(通配符)
- Java学习笔记10(面向对象三:接口)
- Java学习笔记之使用反射+泛型构建通用DAO
- java 学习笔记--利用反射实现泛型数组的复制
- java反射学习笔记(4)----通过反射来了解泛型的本质
- 学习java笔记 --- 一个实现Iterable<E>接口的小范例
- java学习笔记之抽象类,接口,多态
- 《黑马程序员》java笔记->售票例子实现Runnable接口创建线程
- Java笔记(四) 接口与多态
- java中的泛型类型与Type接口
- 【Java 学习笔记】 抽象类和接口
- Java学习笔记14:接口只用于定义类型