作者:丨火云邪神丨 | 来源:互联网 | 2023-05-18 23:55
Imtryingtogetthetypeofanarrayelements.Igotsomethinglikethis:我正在尝试获取数组元素的类型。我有这样的事情:
I'm trying to get the type of an array elements. I got something like this:
我正在尝试获取数组元素的类型。我有这样的事情:
Set mySet = new HashSet();
I have to take via reflection the 'Foo' as a String. I tried something like this:
我必须通过反射将'Foo'作为一个字符串。我试过这样的事情:
if (className.equals("java.util.HashSet")){
Object arrayElement = Array.get(value, 0);
isComplex = isComplex(field, arrayElement);
}
Array.get()
is only for ArrayList and there isn't any HashSet.iterator()
as Util
Array.get()仅用于ArrayList,并且没有任何HashSet.iterator()作为Util
Thanks!
2 个解决方案