static Object goodArrayGrow(Object a){
Class cl=a.getClass();
if(!cl.isArray())
return null;
Class componentType=cl.getComponentType()
int length=Array.getLength(a);
int newLength=length*11/10+10;
Object newArray=Array.newInstance(componentType,newLength);
System.arrayCopy(a,0,newArray,0,length);
retrun newArray;
}
Java动态的增长数组
最新推荐文章于 2022-05-04 15:54:01 发布