System.out.println("Hello|

Dr丶云幕

园龄:3年1个月粉丝:1关注:2

System类

-System类常见的方法和案例

  1. exit退出当前程序
  2. arraycopy:复制数组元素,比较适合底层调用,一般用Arrays.copyOf完成复制数组。
  3. currentTimeMillens:返回当前时间距离1970-1-1的毫秒数
  4. gc:运行垃圾回收机制System.gc();
exit()

public class System_ {
   public static void main(String[] args) {
      System.out.println("hello");
      // System.exit(0); 表示程序退出
      // 0表示一个(正常)状态
      System.exit(0);
      System.out.println("java");
   }
}
System.arraycopy()
 public class System_ {
   public static void main(String[] args) {
      int[] arr={1,2,3};
      int[] arr2=new int[3];

      /*
      Params:
         src – the source array. // 源数组
         srcPos – starting position in the source array. // 从源数组的指定索引位置
         dest – the destination array.    // 拷贝到的目标数组的名称
         destPos – starting position in the destination data.  // 指定拷贝到目标数组的指定位置
         length – the number of array elements to be copied.   // 从源数组拷贝数据个数
       */
      System.arraycopy(arr,0,arr2,0,3);
      System.out.println("复制后的新数组:"+ Arrays.toString(arr2));
   }
}

 

本文作者:Dr丶云幕

本文链接:https://www.cnblogs.com/vayenge/p/18198924

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Dr丶云幕  阅读(6)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起