数组的拷贝

/**
测试数组的拷贝
*/
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]);
      }
  }
  
}
上一篇:java之数组


下一篇:数组复制Arrays.copyOf与System.arraycopy的用法