如何用泛型反射实现List,Array的互相转化

public static Object listToArray(List<? extends AKeyed> list, Class<? extends AKeyed> clazz)

{

if (list == null)

return null;

 

int len = list.size();

Object array = Array.newInstance(

clazz, len);

for (int i = 0; i < len; i++)

{

Array.set(

array, i, list.get(i));

}

return array;

}

阅读更多
换一批

没有更多推荐了,返回首页