//泛类型定义在接口上
interface Inter<T>
{
void show(T t);
}
/* 指定类型
class IterImp implements Inter<String>
{
public void show(String t)
{
System.out.println("show:"+t);
}
}
*/
class IterImp<T> implements Inter<T>
{
public void show(T t)
{
System.out.println("show:"+t);
}
}
class GenericDemo5
{
public static void main(String[] args)
{
IterImp <Integer> i = new IterImp<Integer>();
i.show(4);
}
}
泛类型定义在接口上
最新推荐文章于 2023-11-28 14:09:49 发布