System常用的两个类 currentTimeMills和arraycopy

package cn.dali.code28;

import java.lang.reflect.Array;
import java.util.Arrays;

/*System类常用的两个静态方法
*   public static long currentTimeMills();返回以毫秒为单位的当前系统时间
*   public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length);
*   该方法作用是数组的复制。
*   src是源数组,srcPos为原数组的要复制的起始位置,dest为目标数组,
*   int destPos为目标数组的索引位置,length为复制的长度
*   注意:源数组不动,目标数组是要改变的数组*/
public class Demo01 {
    public static void main(String[] args) {
        /*currentTimeMills可以来计算我们程序的运行时间*/
        long a = System.currentTimeMillis();
        int j = 0;
        for (int i = 0; i < 9999999; i++) {
            j++;
        }
        System.out.println(j);
        long b = System.currentTimeMillis();
        System.out.println("程序运行了"+(b-a)+"毫秒");
        System.out.println("=====================");
        int [] arrayA = new int [] {0,0,0,0,0,0,0};
        int [] arrayB = new int [] {1,1,1,1,1,1,1};
        System.arraycopy(arrayA,0,arrayB,0,2);
        System.out.println(Arrays.toString(arrayA));
        System.out.println(Arrays.toString(arrayB));
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值