Java反射得到数组类定类的 [英] Java reflection getting array class of a given class

查看:132
本文介绍了Java反射得到数组类定类的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这样的C类,我想要得到的类对象重新presents C型重presents的数组。可能吗?我找不到任何方式...

So I have this Class c, and I want to get the Class object that represents an array of the type c represents. Is it possible? I can't find any way...

澄清:别的地方我有:

Class<?> c = Class.forName("data.Person");

OK,所以我有这个类 C 现在。我想有的再presents人的数组。同样的,如果我所做的:

OK, so I have this class c now. And I want to have the Class that represents the array of persons. The same as if I did:

Class<?> cs = data.Person[].class;

不过,我想用反射来做到这一点。我什么都不知道原来的类,但参考 C 来了。

推荐答案

我想你想 Array.newInstance(C,0).getClass()

这篇关于Java反射得到数组类定类的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆