Hi everyone, hope your all well....i was just wondering if someone could pleassseee tell me why this doesnt compile and if they could please correct ti for me??? thank you very much:

public class BankAccount
{
private static int accountCounter = 0;

private String ownerName;
private String accountNumber;
private double accountBalance;
private double overdraftLimit;

public String getOwnerName()
{
return ownerName;
}
public String getAccountNumber()
{
return accountNumber;
}
public double getBalance()
{
return accountBalance;
}
public double getOverdraftLimit()
{
return overdraftLimit;
}

Public BankAccount (string Name, int Balance, int Limit)
{

        public string ownerName = Name;
        public int accountBalance = Balance;
        public int overdraftLimit = Limit;

}

accountCounter++;

this.accountNumber = "" + accountCounter;
}
}

Thnks again!!!

Member Avatar for Dukane

Quite a few problems, but if you look at the errors the compiler is throwing, you will see how to fix it.

For instance, you declare a public String variable called ownerName. But then in the constructor, you have another declaration. This one is also wrong because you have it as string when it would need to be String. It also shouldn't be in the constructor.

Actually, you re-declare all of your instance variables in your constructor which is not necessary.

Then you have the expression accountCounter++ not contained within a method. Same for this.accountNumber = "" + accountCounter.

Seriosuly though, READ the output of the compiler, it's telling you what's wrong and where it is wrong. Fix those errors, and the class will compile. I got it to.

Thanks...i've fixed it up :cheesy:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.