zoukankan      html  css  js  c++  java
  • System.arraycopy() 数组复制

    package com.snape.java._5th.Test61;
    
    public class ArrayCopy {
        public static void main(String[] args) {
            int[] arr1 = {1,2,3,4,5,6,7,8,9};
            int[] arr2 = new int[arr1.length];
    
            System.arraycopy(arr1,0,arr2,0,arr1.length);
    
            System.out.println("原数组:");
            arrayPrint(arr1);
            System.out.println("--------------------------");
            System.out.println("复制得到的数组:");
            arrayPrint(arr2);
        }
    
        //打印数组
        public static void arrayPrint(int[] arr){
            for(int i : arr){
                System.out.print(i + "	");
            }
            System.out.println();
        }
    }

    结果:

  • 相关阅读:
    Docker
    Alfred Workflow
    AWS Lambda
    XPath
    WebMagic
    Splash
    Selenium
    代理服务器
    JSONPath
    Sqlserver 查询分组 记录
  • 原文地址:https://www.cnblogs.com/CPU-Easy/p/12177059.html
Copyright © 2011-2022 走看看