在编译“ AccountTest.java”时出现以下错误...如何解决相同的问题。请帮助我。
AccountTest.java:7: error: constructor BankAccount in class BankAccount cannot be applied to given types;
BankAccount obj = new BankAccount("Clark", 123);
^
required: no arguments
found: String,int
reason: actual and formal argument lists differ in length
BankAccount.java
package AccountPack;
public class BankAccount
{
String CustName;
int AcNumber;
public void BankAccount(String n, int a)
{
CustName = n;
AcNumber = a;
}
public void display()
{
System.out.println("Name: " +CustName);
System.out.println("Account NUmber: " +AcNumber);
}
}
AccountTest.java
import AccountPack.BankAccount;
class AccountTest
{
public static void main (String args[])
{
BankAccount obj = new BankAccount("Clark", 123);
obj.display();
}
}
答案 0 :(得分:1)
您的ontructor应该会这样。
BankAccount(String n, int a)
{
CustName = n;
AcNumber = a;
}