反射:利用泛型在编译过程中被抹去
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)); } }
相关文章推荐
- 利用反射和泛型把Model对象按行储存进数据库以及按行取出然后转换成Model 类实例 MVC网站通用配置项管理
- Java利用反射向集合(List或Map)中存入任意类型的数据(绕过编译阶段)
- asp.net实现利用反射,泛型,静态方法快速获取表单值到Model的方法
- Unity C# 使用反射,利用字符串作为泛型参数调用泛型方法。
- 从编译过程看java的泛型
- 利用泛型和反射编写通用基础类型转换方法
- 利用反射排序泛型List
- 【ZT】利用反射排序泛型List
- C#综合揭秘——利用泛型与反射更新实体(ADO.NET Entity Framework)
- 黑马程序员--Java基础加强--15.利用反射操作泛型IV【通过反射Method解析泛型方法思路】【通过Method对四种Type子接口类型进行解剖】【使用递归对任意复合泛型类型进行彻底解剖】【个人
- 利用泛型和反射,将从数据库select出来的集合直接转换成对象
- 利用Java的反射、泛型以及动态参数实现JDBC工具类
- 【经典实例】利用C#反射动态编译代码,创建类的实例,并调用其成员
- 利用Android反射与泛型机制写一个通用的Adapter类
- 利用反射越过泛型检查
- 利用反射,泛型,静态方法快速获取表单值到Model
- C#综合揭秘——利用泛型与反射更新实体(ADO.NET Entity Framework)
- 利用反射获得WEB应用程序的动态调试编译信息
- 利用反射泛型编写一个通用Dao
- 利用gson处理Java反射TypeToken泛型运行时类型擦除