Java 类中的方法不能应用于给定类型

Java 类中的方法不能应用于给定类型,java,methods,Java,Methods,我试图创建一个方法,该方法在receiver类和argument类之间获得50%的差额,并将其提供给argument类 到目前为止,我已经: private boolean lastReceived; private boolean lastGiven; public Account account; /** * Constructor for objects of class MoneyFrog */ public MoneyFrog(String holderName,

我试图创建一个方法,该方法在receiver类和argument类之间获得50%的差额,并将其提供给argument类

到目前为止,我已经:

private boolean lastReceived;    
private boolean lastGiven;    
public Account account;


/**
* Constructor for objects of class MoneyFrog
*/
public MoneyFrog(String holderName, String accountNumber, double anAmount)
{
    super();
    this.lastReceived = false;
    this.lastGiven = false;
    this.account = new Account();
    this.account.setHolder(holderName);
    this.account.setNumber(accountNumber);
    this.account.setBalance(anAmount);
    super.setColour(OUColour.GREEN);
} 

/**
 * Getter method for the Account variable account
 */
public Account getAccount(Account account)
{
    return this.account;
}

/**
 * Method to transfer the 50% of the difference between the balance of the 
 * receiver MoneyFrog and the argument MoneyFrog to the argument MoneyFrog.
 */
public void transfer(MoneyFrog moneyFrog)
{
 this.getAccount().transfer(moneyFrog.getAccount(),this.getAccount().getBalance()/2);
}
但是代码.getAccount()抛出了错误 MoneyFrog类中的getAccount方法无法应用于给定类型;必需:Account; 发现:没有论点; 原因:实际参数列表和正式参数列表长度不同”


有人能告诉我为什么getAccount方法不能在这里应用吗?或者我应该采取什么其他方法来解决这个问题?

查看方法签名:

public Account getAccount(Account account)
                             ↑
它需要帐户类型为
的对象,您不能写入:

this.getAccount()
没有争论。根据您的类,我认为您不需要将
Account
对象传递给方法,因此将其从方法定义中删除应该可以解决您的问题


我强烈建议您访问以更好地了解Java的基本概念。

getter不带参数,setter带参数。您的
getAccount()
方法使用(未使用的)
Account
参数,您试图调用它而不提供参数。(非常基本的东西,真的。)具体来说,我认为OP的目的是让它不带任何论据。所以应该更改方法签名,而不是调用方。
   /**
    * Getter method for the Account *field* account
    */
   public Account getAccount()
   {
     return this.account;
    }