javasyntax

')' Expected (java)


I seem to be getting a ')' Expected error when I am trying to compile the program

I am not sure what the problem is, as there are no ) missing in the section of code it is indicating is wrong. Below is the code

public void openBankAccount (String firstName, String lastName, String addr1,
                             String addr2, String addr3,
                             String postcode, double openingBalance)
{
    // Hilighted line
    this.account = new BankAccount(String firstName, String lastName,
                                   String addr1, String addr2, String addr3,
                                   String postcode, double openingBalance);


}

Solution

  • You don't need to specify the types of the constructor arguments again, as they're already defined by the constructor signature again:

    new BankAccount(firstName, lastName,addr1, addr2, addr3, postcode, openingBalance);