Flower(String s, int petals) {
    this(petals);
//!    this(s); // Can't call two!
    this.s = s; // Another use of "this"
    System.out.println("String & int args");
  }这句话说明:
this当指代构造方法时( "this(...)" ),在一个构造方法中,只能使用一次,并且放在第一行否则编译出错  void print() {
//!    this(11); // Not inside non-constructor!
    System.out.println(
      "petalCount = " + petalCount + " s = "+ s);
  }这句话指出当this指代构造方法时( "this(...)" ),只能用于构造方法中,不能用于别的方法中Over

解决方案 »

  1.   

    The best way to write this Class:public class Flower
    {
      private String flowerName;
      private int petalCount;  Flower()
      {
        this(null, 0);
      }  Flower(int petals)
      {
        this(null, petals);
      }  Flower(String name)
      {
        this(name, 0);
      }  Flower(String name, int petals)
      {
        flowerName = name == null ? new String(); name;
        petalCount = petals > 0 ? petals : 0;
      }  public String toString()
      {
        return "Flower name is " + flowerName + " with " + petalCount + " petal(s).");
      }  void print()
      {
        System.out.println(this);
      }  public static void main(String[] args)
      {
        Flower x = new Flower();
        x.print();
      }
    }
      

  2.   

    请问 danceflash(Wine) 
    Flower x =ner Flower();
    此时引用,当是具体如何我却搞不清,请大虾指教
      

  3.   

    构造方法在类中只能被其他构造方法调用,并且用this关键字
      

  4.   

    首先调用Flower(),接着利用this调用Flower(String name, int petals)方法.
      

  5.   

    同意 gundam_king(东方不败) ^_^
      

  6.   

    我看的think in java中说在构造器中调用其他构造器,不用this指代,直接调用就可以了。比如两个构造器A()、B(),如果在A()中调用B():A(){B();}就可以了。