泛型:什么是泛型,泛型是JDK1.5的新特性,泛型的本质是类型参数化,相当于C++里面的模板,大量用于集合中。
分类:泛型类,泛型接口,泛型方法
语法:
public class A<T>{ //泛型类
private T t;
}
public int erface IDAO<T>{--------------------泛型接口
public abstract save(T t);
}
public interface B {
public <T> T findById(T t); ---------------泛型方法
}
泛型的有限性:
//Integer Number Serializable
A<? super Integer> a=new A<Number>();
A<?>aa=new A(Integer>();
A<? extends Number> a=new A<Integer>();