草庐IT

getComponentType

全部标签

java - 获取数组组件的类

如果我有publicdoSomething(T[]array){}如何从array获取T.class?如果我执行array.getClass()会得到我的T[].class。 最佳答案 组件类型使用这个:array.getClass().getComponentType()ReturnstheClassrepresentingthecomponenttypeofanarray.Ifthisclassdoesnotrepresentanarrayclassthismethodreturnsnull.引用:Class.getCompon

java - 获取数组组件的类

如果我有publicdoSomething(T[]array){}如何从array获取T.class?如果我执行array.getClass()会得到我的T[].class。 最佳答案 组件类型使用这个:array.getClass().getComponentType()ReturnstheClassrepresentingthecomponenttypeofanarray.Ifthisclassdoesnotrepresentanarrayclassthismethodreturnsnull.引用:Class.getCompon