贴一段数组动态扩容的代码
生活随笔
收集整理的這篇文章主要介紹了
贴一段数组动态扩容的代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
貼一段數組動態擴容的代碼
public static Object arrayGrow(Object obj,int addlength){Class c = obj.getClass(); if(!c.isArray()){ return null;}Class type = c.getComponentType(); int length = Array.getLength(obj); int newlength = length+addlength;Object newArray = Array.newInstance(type, newlength);System.arraycopy(obj, 0, newArray, 0, length); return newArray;} posted on 2013-03-26 09:24?liangge0218 閱讀(...) 評論(...) 編輯 收藏
轉載于:https://www.cnblogs.com/liangge0218/archive/2013/03/26/3292398.html
總結
以上是生活随笔為你收集整理的贴一段数组动态扩容的代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android模拟器怎么与PC通信
- 下一篇: 设计页面实用工具