list泛型类型获取
2015-10-23 00:00
274 查看
Field field = TestList.class.getDeclaredField("list"); //myList的类型是List
Type type = field.getGenericType();
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
Type[] actualTypes = paramType.getActualTypeArguments();
for (Type aType : actualTypes) {
if (aType instanceof Class) {
Class clz = (Class) aType;
System.out.println(clz.getName()); //输出java.lang.String
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Type type = field.getGenericType();
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
Type[] actualTypes = paramType.getActualTypeArguments();
for (Type aType : actualTypes) {
if (aType instanceof Class) {
Class clz = (Class) aType;
System.out.println(clz.getName()); //输出java.lang.String
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
相关文章推荐
- HttpClient4文件上传
- OC学习(二)--之实例变量可见度和方法
- 有了热情就好好干
- 什么是HTML
- phpcms整合Ucenter找回密码无效的解决方法
- phpcms黄页留言复制成在线报名系统
- 解决PHPCMS会员注册未对Ucenter中会员数据进行验证的问题
- DedeCMS首页会员横向登陆的修改代码
- DEDECMS文章模型整合下载功能_可判断点数_会员组等下载权限
- DedeCMS使用Ajax实现搜索下拉提示功能
- ecshop个人收款接口
- SLF4J的静态绑定
- Failed to instantiate the default view controller
- 程序编译成功之后立即退出来,显示Thread1:breakpoint 3.1
- 网页背景不随鼠标滚轮滚动缩放
- iOS实战:第三方登陆weibo/weixin/qq集成
- iOS实战:第一次在iTunesConnect上建立应用时注意公司名称
- 怎样将 FineReader中识别结果保存为XLS和XLSX格式
- USART字符串命令接收与响应
- try-catch-finally块的执行流程