interface Inter<T>
{//接口
void show(T t);
}
/*
class InterImpl implements Inter<String>
{//方式一:在已知类的实现知道具体类型时,
public void show(String t)
{
System.out.println("show :"+t);
}
}
*/
class InterImpl<T> implements Inter<T>
{//方式二:类的实现不知道具体类型时
public void show(T t)
{
System.out.println("show :"+t);
}
}
class GenericDemo5
{
public static void main(String[] args)
{
InterImpl<Integer> i = new InterImpl<Integer>();
i.show(4);
//InterImpl i = new InterImpl();
//i.show("haha");
}
}