Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定 aClass<T>有没有办法在Class<T[]>不首先通过创建数组的情况下获得 a Array.newInstance?即使这样也不能真正达到我想要的效果,因为Array.newInstance会返回 type 的东西Object,所以我仍然会做一个未经检查的演员表。
Class<T>
Class<T[]>
Array.newInstance
Object
使用Class.forName():
Class<?> arrayofTsClass = Class.forName("[L" + tClass.getName() + ";");