泛型定义在接口上
1.
interface Inter<T>{
void show(T t);
}
class InterImpl implements Inter<String>{
public void show(String t){
System.out.println("show :"+t);
}
}
2.
interface Inter<T>{
void show(T t);
}
class InterImpl<T> implements Inter<T>{
public void show(T t){
System.out.println(t);
}
}
3.
我们在使用泛型类的时候,必须为该泛型类传入相应的参数。
|
|