看板 [ java ]
討論串[問題] Integer[] 轉成 int[]
共 3 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓2(2推 0噓 0→)留言2則,0人參與, 最新作者qrtt1 (null)時間16年前 (2009/05/12 09:40), 編輯資訊
0
0
1
內容預覽:
如果你的專案有 Commons Lang 的 ArrayUtils. 那有一個 static method:. public static int[] toPrimitive(Integer[] array) {. if (array == null) {. return null;. } else
(還有262個字)

推噓2(2推 0噓 2→)留言4則,0人參與, 最新作者adrianshum (Alien)時間16年前 (2009/05/11 17:29), 編輯資訊
0
0
0
內容預覽:
推文太久... 回吧. 既然可 result[i]=origin[i] 就代表你在用 JDK 1.5+,. 已有 autoboxing/unboxing. 那麼何必另外弄一個 int[]?. 另, array copy 可用 System.arraycopy.. 直接做 memory copy, 速

推噓2(2推 0噓 1→)留言3則,0人參與, 最新作者naboson (不能說的秘密)時間16年前 (2009/05/11 16:35), 編輯資訊
0
0
0
內容預覽:
如果現在手邊有一個 Integer[] 的陣列. 想要把它轉為 int[]. Integer[] origin;. int[] result = new int[origin.length];. for(int i=0; i<result.length; i++){. result[i] = ori
首頁
上一頁
1
下一頁
尾頁