呵呵,这本书我看过,确实不错的。new 是用来创建对象的阿~!
只有new 了以后,才会分配内存,才能生产这个对象的实例。

解决方案 »

  1.   

    Tree() {
        prt("Planting a seedling");
        height = 0;
      }
      Tree(int i) {
        prt("Creating new Tree that is "
            + i + " feet tall");
        height = i;
      }
    這一段是class Tree 的構造函數,分別代表了兩種情況,
    一個是傳參數Tree t = new Tree(i);調用
      Tree(int i) {
        prt("Creating new Tree that is "
            + i + " feet tall");
        height = i;
      }另一個是不傳參數new Tree();new Tree();僅僅是生成一個實例,但是沒有句柄
      

  2.   

    也是创建tree对象,只不过不赋值给tree变量而已