[Solved] Constructor with two arguments Java


If you want to initialize an empty AccountType object, then you need to add a no argument default constructor.

public AccountType() { }

If you need to set class variables after the object is initialized then you will need to add the appropriate setter methods.

public void setAccountType(String accountNameType){
    this.accountNameType = accountNameType;
}

public void setInterestRate(float interestRate){
    this.interestRate = interestRate;
}

So in your main class.

AccountType accountType = new AccountType();
accountType.setAccountType("savings");
accountType.setInterestRate(10.0);

2

solved Constructor with two arguments Java