【ThinkingInJava】45、用java标准库里面的静态函数调用,复制数组

来源:互联网 发布:ubuntu 离线安装jre 编辑:程序博客网 时间:2024/06/06 02:38
/*** 书本:《Thinking In Java》* 功能:用java标准库里面的静态函数调用,复制数组* 文件:CopyingArrays.java* 时间:2015年4月30日07:42:44* 作者:cutter_point*/package Lesson16Arrays;import static net.mindview.util.Print.*;import java.util.Arrays;public class CopyingArrays{public static void main(String[] args){int[] i = new int[7];int[] j = new int[10];//吧这两个数组分别填充为47和99Arrays.fill(i, 47);Arrays.fill(j, 99);//输出这两个print("i = " + Arrays.toString(i));print("j = " + Arrays.toString(j));//复制数组,参数分别是//* @param      src      the source array.//     * @param      srcPos   starting position in the source array.//     * @param      dest     the destination array.//     * @param      destPos  starting position in the destination data.//     * @param      length   the number of array elements to be copied.System.arraycopy(i, 0, j, 0, i.length);}}


输出:

i = [47, 47, 47, 47, 47, 47, 47]  obj1
j = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]  obj1





0 0
原创粉丝点击