标签:ace div main class space 接受 generic gen person
泛型的使用:
public class Test {
public static void main(String[] args) {
DoWork<Person> doWork = new DoWork<>();
doWork.doSth(new Person());
DoEat<Man> doEat = new DoEat<>();
doEat.doSth(new Man());
}
// 普通类
public static class Person {
}
// 继承上一个普通类
public static class Man extends Person {
}
// 接受泛型的类
public static class DoWork<T> {
public void doSth(T obj) {
}
}
// 泛型的继承
public static class DoEat<T extends Person> {
public void doSth(T obj) {
}
}
}
1、(知识篇)泛型Generic
标签:ace div main class space 接受 generic gen person
原文地址:http://www.cnblogs.com/leaderrida/p/6012678.html