java System.arrayCopy使用说明

java.lang.System.arraycopy() 方法复制指定的源数组的数组,在指定的位置开始,到目标数组的指定位置。

下面是 System.arrayCopy的源代码声明 :

public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
代码解释:
  Object src : 原数组
int srcPos : 从元数据的起始位置开始
  Object dest : 目标数组
  int destPos : 目标数组的开始起始位置
  int length : 要copy的数组的长度

比如 :我们有一个数组数据 byte[]  srcBytes = new byte[]{2,4,0,0,0,0,0,10,15,50};  // 源数组

byte[] destBytes = new byte[5]; // 目标数组

我们使用System.arraycopy进行转换(copy)

System.arrayCopy(srcBytes,0,destBytes ,0,5)
上面这段代码就是 : 创建一个一维空数组,数组的总长度为 12位,然后将srcBytes源数组中 从0位 到 第5位之间的数值 copy 到 destBytes目标数组中,在目标数组的第0位开始放置.
那么这行代码的运行效果应该是 2,4,0,0,0,
我们来运行一下
         byte[]  srcBytes = new byte[]{,,,,,,,,,};
byte[] destBytes = new byte[];
System.arraycopy(srcBytes, , destBytes, , );
for(int i = ;i< destBytes.length;i++){
System.out.print("-> " + destBytes[i]);
}

运行结果  : -> 2-> 4-> 0-> 0-> 0

java System.arrayCopy使用说明的更多相关文章

  1. java System.arraycopy()

    package study.stage2; import java.util.Arrays; /** * Created by Sandy.Liu on 2017/7/19. */public cla ...

  2. JAVA System.arraycopy 和Arrays.copyof 效率比较

    System.arraycopy()源码.可以看到是native方法: native关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件,而是在用其他语言(如C和C++)实现的文件中. ...

  3. java System.arraycopy 数组复制和合并

    public class Test { public static void main(String[] args) { Integer[] a = {1,2,3}; Integer[] b = {4 ...

  4. [Java] System.arraycopy 数组复制

    函数原型: public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) ; s ...

  5. Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V

    最近下载一个新版本的adt-bundle,Android API是20. 把Plain Text控件往布局上面拖时,发现拖不上去,出现了下面的错误: Exception raised during r ...

  6. java的system.arraycopy()方法

    java.lang.System的静态方法arraycopy()可以实现数组的复制,讲课的老师说这个方法效率比较高,如果数组有成千上万个元素,那么用这个方法,比用for语句循环快不少.于是我试了试,发 ...

  7. [Java基础] System.arraycopy使用

    转载自:http://blog.csdn.net/java2000_net/article/details/4059465 System提供了一个native 静态方法arraycopy(),我们可以 ...

  8. ECLIPSE android 布局页面文件出错故障排除Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V

    在布局添加控件手动添加还是拖的添加,添加edittext后布局就不好用,其他控件好用,然后就说下面这段话 Exception raised during rendering: java.lang.Sy ...

  9. java数组的拷贝四种方法:for、clone、System.arraycopy、arrays.copyof

    public class ArrayCopy{ public static void main(String []args){ int []a = {1,3,4,5}; toPrint(a); int ...

随机推荐

  1. pyDay13

    内容来自廖雪峰的官方网站. 1.把list.dict.str等Iterable变成Iterator可以使用iter()函数 >>> L = iter([1, 2, 3, 4, 5, ...

  2. Vue学习笔记之Vue的面向对象

    0x00 准备工作 JavaScript 语言中,生成实例对象的传统方法是通过构造函数. function Animal(name,age){ this.name = name; this.age = ...

  3. 前端学习笔记之CSS过渡模块

    阅读目录 一 伪类选择器复习 二 过渡模块的基本使用 三 控制过渡的速度transition-timing-function 四 过渡模块连写 一 伪类选择器复习 注意点: #1 a标签的伪类选择器可 ...

  4. 前端学习笔记之CSS后代选择器、子元素选择器、相邻兄弟选择器区别与详解

    派生选择器用的很多,派生选择器具体包括为后代选择器.子元素选择器.相邻兄弟选择器,我们来理解一下他们之间的具体用法与区别. 1.css后代选择器语法:h1 em {color:red;} 表示的是从h ...

  5. 如何把js的循环写成异步的

    针对这里的问题:深入理解node.js异步编程:基础篇https://cnodejs.org/topic/533d6edbc2621e680800e0ea 这一节有一个代码:###4.1 Node.j ...

  6. 使用索贝尔(Sobel)进行梯度运算时的数学意义和代码实现研究

    对于做图像处理的工程师来说,Sobel非常熟悉且常用.但是当我们需要使用Sobel进行梯度运算,且希望得到“数学结果”(作为下一步运算的基础)而不是“图片效果”的时候,就必须深入了解Sobel的知识原 ...

  7. YouCompleteMe自动补全的安装配置与使用

    1 下载 git clone --recursive git://github.com/Valloric/YouCompleteMe 如果执行该命令没报错, 就ok了. 但是中途有可能会断掉, 可以 ...

  8. CPA定律——一致性,可用性和分区容错性

    按照美国著名科学家 Eric Brewer 在 2000 年提出的理论,当技术架构从集中式架构向分布式架构演进,会遇到 “CAP 定律”的瓶颈. CAP 说明一个数据处理系统不能同时满足一致性,可用性 ...

  9. ExtJS错误解决 Cannot read property 'on' of undefined

    背景 用ExtJS新写了一个功能,运行时控制台打印错误Cannot read property 'on' of undefined,出错代码位置是Ext.define.bindStoreListene ...

  10. ArrayList扩容

    jdk1.5 public ArrayList(int initialCapacity) { super(); if (initialCapacity < 0) throw new Illega ...