3.4. Create an overloaded method

[6.1] Create methods with arguments and return values; including overloaded methods

Overloaded methods are methods with the same name but different method parameter lists. In this section, you’ll learn how to create and use overloaded methods.

Imagine that you’re delivering a lecture and need to instruct the audience to take notes using paper, a smartphone, or a laptop—whichever is available to them for the day. One way to do this is give the audience a list of instructions as follows:

  • Take notes using paper.
  • Take notes using a smartphone.
  • Take notes using a laptop.

Another method is to instruct them to “take notes” and then provide them with the paper, a smartphone, or a laptop they’re ...

Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.