好吧,我正在爲學校做一份作業,並且設立了我的主類和另一個叫做Transaction的類。在我的主類中,我有:Java構造函數未定義?
Transaction t = new 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才能入門。 – 2010-09-11 05:30:35
我建議你也檢查你的變量名稱。另外,如果你沒有使用它們,爲什麼在構造函數中設置'f'和'g'? – 2014-01-30 22:19:06