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

          2.
          JDK 1.5 新增

          增強(qiáng)的“for”循環(huán)(Enhanced For loop--減少迭代器(iterator)的潛在錯(cuò)誤(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});
          這條語(yǔ)句可以使printArray輸出3 1 2 6 4 2,卻并沒有向printArray傳遞一個(gè)數(shù)組的引用,這種數(shù)組稱為
          anonymous array

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

          7.
          編了個(gè)算法導(dǎo)論上的快速排序
          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 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          1.23 Java notes

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


          網(wǎng)站導(dǎo)航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 嫩江县| 斗六市| 沁源县| 临泽县| 葫芦岛市| 枣庄市| 深泽县| 清镇市| 富裕县| 鱼台县| 宁城县| 进贤县| 龙陵县| 广灵县| 衡东县| 三亚市| 滨州市| 沁阳市| 慈利县| 台前县| 乌兰浩特市| 平度市| 桐柏县| 阳江市| 阳谷县| 阿拉善左旗| 娱乐| 元谋县| 勐海县| 商丘市| 霍州市| 林州市| 五峰| 利辛县| 喜德县| 林口县| 若羌县| 古交市| 九江市| 诸暨市| 襄樊市|