您的位置:首页 > 编程语言 > Java开发

Java 泛型定义在接口上

2016-04-21 15:50 711 查看
//泛型定义在接口上。
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");
}
}


————摘自《毕向东25天》
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  泛型