Results 1 to 3 of 3
  1. #1
    jazzermonty is offline Member
    Join Date
    Jan 2011
    Posts
    71
    Rep Power
    0

    Default What's wrong with this method?

    Hi folks

    I've written a method, code below

    Java Code:
    public void transfer(MoneyFrog aFrog){
           double aDouble;
           aDouble = this.account.getBalance();
           this.account.transfer(aFrog aDouble);
          }
    but keep getting the error ')' expected on the following line:

    Java Code:
    this.account.transfer(aFrog aDouble);

    The line this.account.transfer(aFrog aDouble) calls a method in another object (account no less) that has two arguments of Account(the MoneyFrog object in this case) and a double (aDouble).

    Here's the method in the Account class:

    Java Code:
     public boolean transfer(Account toAccount, double anAmount)
       {
          if (this.debit(anAmount))
          {
             toAccount.credit(anAmount);
             return true;
          }
          else
          {
             return false;
          }
    What's wrong with my syntax here? I can't figure it out.

    Thanks i advance

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Don't you think you are missing a comma between the parameters?
    Java Code:
    this.account.transfer(aFrog aDouble);
    should be
    Java Code:
    this.account.transfer(aFrog, aDouble);
    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    jazzermonty is offline Member
    Join Date
    Jan 2011
    Posts
    71
    Rep Power
    0

    Default

    Quote Originally Posted by goldest View Post
    Don't you think you are missing a comma between the parameters?
    Java Code:
    this.account.transfer(aFrog aDouble);
    should be
    Java Code:
    this.account.transfer(aFrog, aDouble);
    Goldest
    Ah, Goldest. Thanks once again for your patience. You can tell I'm a newbee at this game. It all works fine now.

    Cheers

Similar Threads

  1. Replies: 4
    Last Post: 06-11-2013, 01:37 AM
  2. method return statement is wrong
    By ftrengnr in forum New To Java
    Replies: 1
    Last Post: 10-19-2010, 04:15 AM
  3. Replies: 2
    Last Post: 03-26-2010, 05:12 PM
  4. print out error method for wrong args.
    By Implode in forum New To Java
    Replies: 9
    Last Post: 09-20-2009, 12:46 PM
  5. What did i do wrong on thing method?
    By PureAwesomeness in forum New To Java
    Replies: 9
    Last Post: 03-08-2009, 08:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •