您的位置:首页 > 其它

反射:利用泛型在编译过程中被抹去

2011-09-17 23:14 253 查看
package cn.itcast.day1;

import java.util.ArrayList;

public class GenericTest {

/**
* @param args
*/
public static void main(String[] args)throws Exception{
// TODO Auto-generated method stub
ArrayList<Integer> collection1=new ArrayList<Integer>();
collection1.add(1);
collection1.add(3);
collection1.add(9);
collection1.getClass().getMethod("add",Object.class).invoke(collection1, "ligang");
System.out.println(collection1.get(3));
}

}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐