Static Builder and Create Methods for simple class
I was told by my instructor to include a static builder method and static create method as part of good class design in all my programs, the problem is, I don't understand how I would use other non-static methods associated with the class. Here are the two methods:
If I use these methods with a class named BankAccount, like
public static BankAccount Create(String name, int accountNumber, double balance)
BankAccount anAccount = null;
anAccount = new BankAccount(name, accountNumber, balance);
public static BankAccount Builder()
BankAccount anAccount = new BankAccount();
how (if it is even possible) can I use non-static methods like 'withdraw' or 'deposit' to modify the balance or other instance variables? The static methods create a new account, 'anAccount', but I cannot use non-static methods with anAccount.withdraw. I simply just don't understand what the purpose of these static methods in a class are if non-static methods cannot be used. Please help!
BankAccount.Create(Johnson, 3233, 100)
thanks, that's what I was looking for...