- X 2
So it could be
and toString would not have to be defined on BankAccount in that case.
Ralph Cook wrote:
...and toString would not have to be defined on BankAccount in that case.
I don't think it is a good idea.
From the API docs of toString()
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
As you can see it makes lots of sense to override the toString()
Your post was moved to a new topic.
I would suggest you give your BankAccount class some getXXX methods. Then you could call. . . or similar.
Oh, one last thing, don't try to scan text with nextLine(); AFTER using nextInt() with the same scanner! It doesn't work well with Java Scanner, and many Java developers opt to just use another Scanner for integers. You can call these scanners scan1 and scan2 if you want.
I would personally always input strings, then error-check for input of an int before proceeding.
I couldn't get the previous link to open: try this instead if you have the same problem.