如何创建一个使用另一个类的变量或调用整个构造函数的 java 对象?
比如accountNumber, firstName, lastName, phone都是传入address的变量,由street, city, state, zip组成,已经创建好了:
Address address = new Address(street, city, state, zip);
数据仅由兆字节组成,并且已经创建:
Data data = new Data(megabytes);
这就是我对客户对象的看法:
Customer customer = new Customer(accountNumber, firstName, lastName, address, phone, data);
这应该是一个“重载的构造函数”,但我不明白那是什么意思。
这是我到目前为止的构造函数:
public Customer(String accountNumber, String firstName, String lastName, Address address, int phone, Data megabytes)
{
this.accountNumber = accountNumber;
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.megabytes= megabytes;
}
我收到错误:
The constructor Customer(String, String, String, Address, int, Data) is undefined
12345678_0001
相关分类