只需创建一个新的实例你没有入口点到您的程序,这看起来应该像这样在你的类
public static void main(String[] args)
{
//objects created here
}
您还会创建一个Customer
对象作为您的Customer
类的成员,这意味着每个对象都包含另一个对象。
你不能设置Customer
成员这样
Customer customer = new Customer(); //you also don't have a no argument constructor
customer = 1; //how would it know where to put this 1?
customer = cust1; //same as above
它会是这样(如果他们在正确的地方,如上面提到的)
Customer customer = new Customer(); //if using this method you will need a no argument constructor
customer.id = 1;
customer.name = cust1;
或类似这样的
new Customer(1,"cust1");
总结
- 你需要一个切入点
- 你有没有参数的构造函数创建
Customer
但你只有它有两个参数一个构造
- 您是 - 对于一些reason-每
Customer
内创建
Customer
- 你没有设置你的
Customer
对象的成员在正确的(甚至是在一个有效的)方式
那么,有什么问题呢? –