數(shù)據(jù)加載中……
          ArrayCopy.java
          /**
          *測試數(shù)組元素的拷貝
          */
          public class ArrayCopy{
          public static void main(String[] args){
          ArrayCopy aCopy=new ArrayCopy();
          int[] a={1,2,3,4,5};
          int[] b={10,20,30,40,50};
          aCopy.copy(a,b);
          }
          public void copy(int[] from,int[] to){
          System.out.println("第一個數(shù)組中的元素");
          for(int i=0;i<from.length;i++){
          System.out.println("   "+from[i]);
          }System.out.println("\n");
          System.out.println("第二個數(shù)組中的元素");
          for(int i=0;i<to.length;i++){
          System.out.println("   "+to[i]);//打印出數(shù)組中的每一個元素
          }
          System.out.println("\n\n將第一個數(shù)組拷貝到第二個數(shù)組\n");
          System.arraycopy(from,2,to,0,3);
          System.out.println("拷貝完成后第二個數(shù)組中的元素");
          for(int i=0;i<to.length;i++){
          System.out.println("  "+to[i]);//打印出數(shù)組中的每一個元素}}}

          posted on 2008-10-21 21:13 郭興華 閱讀(268) 評論(0)  編輯  收藏 所屬分類: TESTARRAY


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 云霄县| 临安市| 兴海县| 衡东县| 连云港市| 平乡县| 宜黄县| 伽师县| 双城市| 天台县| 常宁市| 光山县| 海阳市| 常山县| 兴国县| 抚松县| 安远县| 辽中县| 耿马| 工布江达县| 凤台县| 达尔| 民权县| 遂昌县| 黄龙县| 龙泉市| 剑河县| 灌南县| 小金县| 太谷县| 桐柏县| 定结县| 深泽县| 内乡县| 德阳市| 台江县| 阆中市| 峨眉山市| 民和| 赞皇县| 唐海县|