List.class,报错,为啥?

雨中的月儿 2015-09-22 07:23:13
函数如下:

public static <T> T ReadJson(String _strJson, Class<T> _class)
{
}


调用代码为:

List<int> bean = ReadJson(strJson, List<int>.class);


在Eclipse里的错误提示为:
Multiple markers at this line
- Syntax error on token ">", delete this token
- Syntax error, insert "Dimensions" to complete
ReferenceType

请高手帮忙 !
...全文
354 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
解开者 2015-09-23
  • 打赏
  • 举报
回复
泛型是编译行为,在运行时不存在,所以编译器不允许运行时获取泛型类型
邹邹wl 2015-09-22
  • 打赏
  • 举报
回复
List.class不就行了吗
zhuangqingch 2015-09-22
  • 打赏
  • 举报
回复
java的泛型中的参数是不允许使用原始类型的。都需要用引用类型。如Integer。 另外List<int>.class这种获取Class对象方式在java中是不支持的。应修改为List.class
远东悟语 2015-09-22
  • 打赏
  • 举报
回复
修改int为 Integer 试一试吧

62,630

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧