我创建了我的主要用途构造函数并传递了三个参数。默认参数之上的参数。目标是将第一个字段(名称)设置为默认值(假设用户未输入名称)。问题在于信用限额和电子邮件,我收到以下错误。这是为什么?我不明白是什么?以及修复措施是什么。
- Cannot refer to an instance field creditLimit while explicitly invoking a
constructor
- Cannot refer to an instance field email while explicitly invoking a
public class VipCustomer {
private String name;
private int creditLimit;
private String email;
public VipCustomer()
{
this("Default",creditLimit,email);
}
public VipCustomer(String name, int creditLimit, String email) {
// TODO Auto-generated constructor stub
this.name = name;
this.creditLimit = creditLimit;
this.email = email;
}
public String getName()
{
return this.name;
}
public int getCreditLimit()
{
return creditLimit;
}
慕村9548890
慕斯王
烙印99
相关分类