posts - 75,comments - 83,trackbacks - 0
          posted @ 2008-07-23 22:18 梓楓 閱讀(667) | 評論 (0)編輯 收藏
          posted @ 2008-07-22 16:31 梓楓 閱讀(3563) | 評論 (5)編輯 收藏
               摘要: 增強的for循環
             為了迭代集合和數組,增強的for循環提供了一個簡單、兼容的語法。有兩點值得一提:   Init表達式

            在循環中,初始化表達式只計算一次。這意味著您通常可以移除一個變量聲明。在這個例子中,我們必須創建一個整型數組來保存computeNumbers()的結果,以防止每一次循環都重新計算該方法。您可以看到,下面的代碼要比上面的代碼整潔一些,并且沒有泄露變量numbers:

            未增強的For:  int sum = 0;  Integer[] numbers = computeNumbers();  for (int i=0; i < numbers.length ; i++) sum += numbers[i];   增強后的For:    int sum = 0;  for ( int number: computeNumbers() ) sum += number;......
            閱讀全文
          posted @ 2008-07-21 23:01 梓楓 閱讀(258) | 評論 (0)編輯 收藏
          posted @ 2008-07-21 14:09 梓楓 閱讀(2291) | 評論 (1)編輯 收藏
          posted @ 2008-07-20 22:14 梓楓 閱讀(3394) | 評論 (2)編輯 收藏
          posted @ 2008-07-14 15:42 梓楓 閱讀(750) | 評論 (0)編輯 收藏
          posted @ 2008-06-30 15:37 梓楓 閱讀(5187) | 評論 (12)編輯 收藏
          posted @ 2008-06-30 15:14 梓楓 閱讀(37391) | 評論 (6)編輯 收藏
          posted @ 2008-06-30 10:36 梓楓 閱讀(494) | 評論 (0)編輯 收藏
          posted @ 2008-06-12 15:27 梓楓 閱讀(1691) | 評論 (0)編輯 收藏
          posted @ 2008-05-19 16:37 梓楓 閱讀(5576) | 評論 (2)編輯 收藏
          posted @ 2008-05-19 15:53 梓楓 閱讀(202) | 評論 (0)編輯 收藏
          posted @ 2008-05-06 17:05 梓楓 閱讀(1977) | 評論 (1)編輯 收藏
          posted @ 2008-04-19 16:59 梓楓 閱讀(417) | 評論 (0)編輯 收藏
          posted @ 2008-04-18 20:35 梓楓 閱讀(295) | 評論 (0)編輯 收藏
          posted @ 2008-04-17 20:15 梓楓 閱讀(443) | 評論 (0)編輯 收藏
          posted @ 2008-04-17 19:27 梓楓 閱讀(1834) | 評論 (0)編輯 收藏
          posted @ 2008-04-17 13:56 梓楓 閱讀(735) | 評論 (0)編輯 收藏
          posted @ 2008-03-31 15:27 梓楓 閱讀(9669) | 評論 (9)編輯 收藏
          posted @ 2008-03-25 10:54 梓楓 閱讀(304) | 評論 (0)編輯 收藏
          列出全部內容
          共4頁: 上一頁 1 2 3 4 下一頁 
          主站蜘蛛池模板: 察雅县| 河北省| 双鸭山市| 遂昌县| 鄯善县| 霍州市| 宣武区| 页游| 乌拉特中旗| 天等县| 峡江县| 阿鲁科尔沁旗| 南昌市| 平遥县| 博白县| 宁国市| 长治市| 台中市| 含山县| 临潭县| 大连市| 永城市| 兰坪| 诏安县| 汝南县| 松桃| 衡水市| 长治县| 舟山市| 东乡县| 神农架林区| 桐梓县| 内江市| 沅陵县| 新兴县| 金华市| 石楼县| 宣汉县| 烟台市| 陵川县| 新丰县|