隨筆 - 64  文章 - 9  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(6)

          我參與的團隊

          隨筆分類(88)

          隨筆檔案(92)

          文章分類(142)

          文章檔案(182)

          天基成員

          學習園

          我的海角

          搜索

          •  

          積分與排名

          • 積分 - 183418
          • 排名 - 319

          最新評論

          1.for(ElementType element:arrayName){};   
          2.(1).            int[] numArray = { 1, 2, 3, 4, 5, 6 };    
                               for (int i : numArray) {   
                                   System.out.print(i);     
                                }   
          ----//結(jié)果會是123456

           

          等價于            


          2). int[] numArray = { 1, 2, 3, 4, 5, 6 };     
          for (int i; i < numArray.length; i++) {     
            System.out.print(numArray[i]);     
          }   

           

          或者更貼切是這樣的:(3)
          Java代碼
          3).int[] numArray = { 1, 2, 3, 4, 5, 6 };     
          for (int i; i < numArray.length; i++) {     
            int j = numArray[i];// 這個j,就等價與(1)中的i     
            System.out.println(j);     
          }   

           

          3.      這個結(jié)合集合的概念和同樣是JDK1.5加入的泛性,可以做到簡化代碼的作用.比如

          Java代碼
          List<Integer> intList = new ArrayList<Integer>();     
          for (Integer i : intList) {     
            System.out.print(i);// 可以打印出intList中的所有元素     
          }    

          posted on 2009-04-09 19:36 鵬凌 閱讀(1335) 評論(0)  編輯  收藏

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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 客服| 诏安县| 太康县| 合川市| 凤凰县| 台中县| 上犹县| 清涧县| 平南县| 甘洛县| 威远县| 南皮县| 太和县| 崇义县| 永昌县| 泗水县| 新田县| 金乡县| 随州市| 林口县| 黄山市| 崇礼县| 财经| 八宿县| 郎溪县| 家居| 四川省| 昌黎县| 大悟县| 兰州市| 连云港市| 邻水| 邯郸市| 龙泉市| 巫溪县| 富源县| 西昌市| 渭南市| 尼木县| 元阳县| 清新县|