问题
Given a Class<?> that describes class A, is it somehow possible to get the Class<?> that matches the class A[]?
Class<?> clazz = A.class;
Class<?> arrayclazz = clazz.toArray(); // ??
assert arrayclazz.equals(A[].class);
回答1:
java.lang.reflect.Array.newInstance(clazz, 0).getClass()
回答2:
use A[].class. I hope this help.
来源:https://stackoverflow.com/questions/5091348/getting-the-array-class-of-a-given-class