【发布时间】:2011-04-11 00:48:28
【问题描述】:
好的,我正在为学校做作业,我设置了我的主要课程和另一个名为 Transaction 的课程。在我的主要课程中,我有:
Transaction t = new Transaction();
Transaction 有下划线:它表示构造函数未定义。为什么?!
Transaction 类如下所示:
public class Transaction {
private String customerNumber, fName, lName, custAddress, custCity;
private int custZip, custPhone;
/** Constructor*/
public Transaction(String a, String b, String c, String d, String e, int f, int g){
this.customerNumber = a;
this.fName = b;
this.lName =c;
this.custAddress = d;
this.custCity = e;
}
看起来它应该可以正常工作,但事实并非如此。即使我将一堆变量插入到我在 main 中创建新 Transaction 对象的位置,它仍然显示未定义。有人请帮忙!
【问题讨论】:
-
看来您至少需要阅读一些 Java 101 才能开始使用。
-
我建议你也检查一下你的变量名。另外,如果您不使用所有这些,为什么要在构造函数中参数化
f和g?
标签: java methods constructor