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 閱讀(104) 評論(0)  編輯  收藏 所屬分類: OOP
          2007-01-23 22:47:56
          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 临颍县| 黄骅市| 屯门区| 康马县| 孙吴县| 鸡东县| 富阳市| 松溪县| 娄底市| 襄汾县| 惠州市| 石河子市| 仁寿县| 隆尧县| 上杭县| 揭阳市| 丹寨县| 双江| 呼伦贝尔市| 时尚| 清河县| 定日县| 南宫市| 昌吉市| 石嘴山市| 潼关县| 乌鲁木齐县| 大连市| 板桥市| 武穴市| 南京市| 三河市| 乐安县| 滦南县| 全州县| 观塘区| 固阳县| 清丰县| 晴隆县| 精河县| 繁峙县|