Java面试题26中哪种数组复制方法效率最高?
发布时间
阅读量:
阅读量
在Java语言中,针对数组复制的多种实现方式,哪一种的执行效率最为优越?
A for 循环逐一复制
B System.arraycopy
C Array.copyOf
D 使用clone方法
性能:System.arraycopy > clone > Arrays.copyOf > for循环
1、System.arraycopy的使用方式:
public static void arraycopy(Object src,
int srcPos,
Object dest,
int destPos,
int length)
参数:src - 源数组;srcPos - 源数组中开始复制的位置;dest - 用于存放数据的目标数组;destPos - 目标数组中开始写入数据的起始点;lengt
全部评论 (0)
还没有任何评论哟~
