System.arraycopy
生活随笔
收集整理的這篇文章主要介紹了
System.arraycopy
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
System.arraycopy的方法原型:
public static native void arraycopy(Object src, int srcPos,Object dest, int destPos,int length);src : 源數(shù)組
srcPos : 源數(shù)組要復(fù)制的起始位置(從0開始)
dest : 目標(biāo)數(shù)組
destPos : 原數(shù)組內(nèi)容復(fù)制到目標(biāo)數(shù)組的起始位置(從0開始)
length : 要復(fù)制源數(shù)組的長(zhǎng)度(長(zhǎng)度從1開始)
實(shí)例:
把兩個(gè)數(shù)組合并成一個(gè)數(shù)組
public void findMedianSortedArrays(int[] a, int[] b) {int[] c= new int[a.length+b.length];System.arraycopy(a, 0, c, 0, a.length);System.arraycopy(b, 0, c, a.length, b.length);Arrays.sort(c);System.out.println(Arrays.toString(c));}總結(jié)
以上是生活随笔為你收集整理的System.arraycopy的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: u盘怎么格式化失败怎么办 U盘格式化失败
- 下一篇: (看这一篇就够了)基本数据类型的赋值与引