public class Clothing implements MilkTeaBreak{
public float price;
public String name;
public Clothing() {
super();
// TODO Auto-generated constructor stub
}
public Clothing(float price, String name) {
super();
this.price = price;
this.name = name;
}
构造函数的特点:
- 与类一致
- 可以有多个构造函数
- 没有返回值
- 参数可以多个
- 通常用new或者类来实现
构造函数的作用:
- 初始化
- 提高灵活度