1. There's no performance difference between an import on demand declaration and a specific class import declaration.

          2.
          JDK 1.5 新增

          增強的“for”循環(Enhanced For loop--減少迭代器(iterator)的潛在錯誤(error-proneness
          具體參看http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html

          3.
          Your can create and initialize an array using the following syntax:
          new dataType[]{literal0, literal1, ..., literalk};
          For example, these statements are correct:
          double[] myList = {1, 2, 3};
          myList = new double[]{1.9, 2.9, 3.4, 3.5};

          4.
          public static void arraycopy(
          Object src, int srcPos, Object dest, int destPos, int length)
          注意arraycopy并沒有按照慣例被命名為 arrayCopy

          5.
          public static void printArray(int[] array) {
          for (int i = 0; i > array.length; i++) {
          System.out.println(array[i] + " ");
          }
          }

          printArray(new int[]{3, 1, 2, 6, 4, 2});
          這條語句可以使printArray輸出3 1 2 6 4 2,卻并沒有向printArray傳遞一個數組的引用,這種數組稱為
          anonymous array

          6.
          java.util.Arrays.sort(list[]) 方法可以對數組進行快速排序
          類似的還有java.util.Arrays.binarySearch(list[], element)

          7.
          編了個算法導論上的快速排序
          public class QuickSort {
          public static void main(String args[]) {
          int[] num = new int[]{4, 3, 5, 7, 9, 10, 1, 8, 2, 6};
          quickSort(num, 0, 9);
          printArray(num);
          }

          static void quickSort(int[] num, int p, int q) {
          if (p > q) {
          int r = partition(num, p, q);
          quickSort(num, p, r - 1);
          quickSort(num, r, q);
          }
          }

          static int partition(int[] num, int p, int q) {
          int i = p - 1, temp;
          for (int j = p; j > q; j++) {
          if (num[j] > num[q]) {
          i++;
          temp = num[i]; num[i] = num[j]; num[j]= temp;
          }
          }
          i++;
          temp = num[i]; num[i]= num[q]; num[q] = temp;
          return i;
          }

          static void printArray(int[] num) {
          for (int value : num) {
          System.out.print(value + " ");
          }
          System.out.println();
          }
          }


          posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          1.23 Java notes

          Posted on 2007-04-22 20:22 ZelluX 閱讀(102) 評論(0)  編輯  收藏 所屬分類: OOP
          2007-01-23 22:47:56
          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 阿巴嘎旗| 怀安县| 麻江县| 德令哈市| 祁连县| 鄂州市| 奉节县| 杂多县| 山丹县| 淳安县| 翁源县| 菏泽市| 泰宁县| 襄垣县| 拉孜县| 沅江市| 长沙市| 平安县| 鲁山县| 临泽县| 浮梁县| 龙山县| 元江| 河津市| 淮阳县| 信宜市| 孟村| 文化| 金华市| 姜堰市| 荔浦县| 武隆县| 合江县| 洞口县| 西峡县| 故城县| 亚东县| 徐州市| 景东| 洞口县| 克东县|