Skip to content

关于ArrayList中的Arrays.copy()中的建议 #1193

@jtMook

Description

@jtMook

建议可以把Arrays.copy()和System.arraycopy()的源码附上去
是关于ArrayList的文章入口
Arrays.copyOf()

public static int[] copyOf(int[] original, int newLength) {
        //newLength 要返回的副本的长度
        int[] copy = new int[newLength];
        System.arraycopy(original, 0, copy, 0,
                         Math.min(original.length, newLength));
        return copy;
    }




System.arraycopy()

public static native void arraycopy(Object src,  int  srcPos,
                                    Object dest, int destPos,
                                    int length);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request or suggestion

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions