public class Apple
{
public String name;
public String color;
public double weight;
public Apple(){}
public Apple(String name,String color)
{
this.name = name;
this.color = color;
}
public Apple(String name , String color , double weight)
{
this(name , color);
this.weight = weight;
}
}
这个代码中
为什么要用this来调用另一个重载的构造器?我把另一个构造器里的代码复制、粘贴到这个构造器里不就可以嘛?
|
|