A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 蓦然回首3Y 中级黑马   /  2015-6-29 11:19  /  335 人查看  /  7 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

接口上有泛型,实现它的时候可以不去理会、不写泛型吗?

7 个回复

倒序浏览
自己用eclipse亲自写个实例看看就知道了
回复 使用道具 举报
可以不写,就是警告
回复 使用道具 举报
可以不写的
回复 使用道具 举报
//泛型定义在接口上。 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");         } }
回复 使用道具 举报
明白了,谢谢
回复 使用道具 举报
学习了  
回复 使用道具 举报
可以省略
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马