Method overloading is a feature common to most object-oriented programming languages and
is one aspect of polymorphism. This allows us to have methods with the same identifier but
with different argument lists. The argument lists can have a different ordering of data types
or can have a different number of arguments. In the Account class, in addition to the deposit
method we have already seen (lines 12-14), we could also add a second deposit method that
prints the balance if it exceeds a supplied level.
public void deposit(double amount, double level) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.