其他分享
首页 > 其他分享> > 数组的拷贝

数组的拷贝

作者:互联网

/**
测试数组的拷贝
*/
public class TestArraycopy {

  public static void main(String[] args) {
      //System.arraycopy(src, srcPos, dest, destPos, length);
      String[] s1 = {"aa", "bb" ,"cc", "dd", "ee"};
      String[] s2 = new String[10];
      System.arraycopy(s1, 2, s2, 6, 3);
      
      //遍历
      for(int i=0; i<s2.length; i++) {
          System.out.println(i+"---"+s2[i]);
      }
  }
  
}

标签:String,s2,s1,System,public,数组,拷贝,arraycopy
来源: https://www.cnblogs.com/nongeason/p/15140322.html