加载中...

数组的拷贝

/**
测试数组的拷贝
*/
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]);
      }
  }
  
}
posted @ 2021-08-14 10:51  nongeason  阅读(31)  评论(0)    收藏  举报