数组copy方法
来源:互联网 发布:数据库流程 编辑:程序博客网 时间:2024/05/16 10:36
public class TestArrayCopy {
public static void main(String[] args) {
int[] a = {1, 2, 5, 7, 9, 10};
int[] b = new int[6]; //定义并初始化数组b,注意要new出长度
TestArrayCopy test = new TestArrayCopy();
System.out.print("a数组元素:");
test.print(a);
System.out.print("b数组元素:");
test.print(b);
System.arraycopy(a, 0, b, 0, a.length); //copy a从0位开始 到 b的0位开始,copy长度为a数组自身的长度
System.out.print("b数组元素:");
test.print(b);
}
private void print(int[] num) { //输出方法
for(int temp : num) {
System.out.print(temp + " ");
}
System.out.println();
}
}
public static void main(String[] args) {
int[] a = {1, 2, 5, 7, 9, 10};
int[] b = new int[6]; //定义并初始化数组b,注意要new出长度
TestArrayCopy test = new TestArrayCopy();
System.out.print("a数组元素:");
test.print(a);
System.out.print("b数组元素:");
test.print(b);
System.arraycopy(a, 0, b, 0, a.length); //copy a从0位开始 到 b的0位开始,copy长度为a数组自身的长度
System.out.print("b数组元素:");
test.print(b);
}
private void print(int[] num) { //输出方法
for(int temp : num) {
System.out.print(temp + " ");
}
System.out.println();
}
}
0 0
- 数组copy方法
- copy一个数组的方法
- JS 数组操作的方法--COPY
- list.copy方法-深浅copy
- 自定义方法copy数组 和 Java类库对数组复制的支持
- 自定义方法copy数组 和 Java类库对数组复制的支持
- [java]数组间copy
- DataTable.Copy 方法
- clone()方法copy
- Copy文件的方法
- Array.Copy 方法 总结
- Array.Copy 方法
- 重写 copy 方法
- UIImage的copy方法
- angular.copy方法
- copy的set方法
- copy文章方法
- vector C++ copy方法
- C++智能指针auto_ptr源码完全解析---以微软auto_ptr为例来探讨auto_ptr的用法
- 重写
- HTML5表单验证的例子
- PHP时间函数date()详解
- HDU 2121 Ice_cream’s world II (不定根最小树形图)
- 数组copy方法
- JAVA MD5加密的两种方法
- 华为在线测试题[基础篇]--求小球落地5次后所经历的路程和第5次反弹的高度
- Eclips中的快捷键
- 求助!用openlayers如何实现读入数据库的地理位置信息,然后进行实时同步定位??万分感谢!
- 黑马程序员——c语言基础:数组和字符串
- android apk 防止反编译技术第四篇-对抗JD-GUI
- 7. HCNP-R&S-IERN——OSPF外部路由技术
- 【文献笔记】短文本分析