java容器--------泛型
package cn.zxg.collection; /** * 测试泛型 */ public class TestGenric { public static void main(String[] args) { MyCollection
mc=new MyCollection<>(); mc.set("小白",1); mc.set("小黑",2); String b=mc.get(1); System.out.println(b); } } class MyCollection
{ Object[] obj=new Object[5]; public void set(E e,int index){ obj[index]=e; } public E get(int index){ return (E)obj[index]; } }
猜你喜欢
转载自www.cnblogs.com/zzzao/p/10914967.html
今日推荐
周排行