From the course: Java Cheat Codes: Most Popular Functions
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Method overloading - Java Tutorial
From the course: Java Cheat Codes: Most Popular Functions
Method overloading
- [Instructor] Method overloading. Here's an explanation of how to define multiple methods with the same name, but different parameter lists, known as method overloading. It's like we have people at work with the same name. We figure out a way to differentiate what do we call each of them? A more formal definition of method overloading is a feature in Java that allows you to create multiple methods with the same name, but different parameter lists, and the purpose of this is to provide flexibility in method calls, and it allows you to handle different types of input or perform slightly different actions based on the arguments provided. There are a few rules for method overloading. One of them is that the parameter lists must differ. The method must have different numbers of parameters or the types of the parameters must differ in order for them to be considered overloaded. The return type alone does not count. Overloaded methods can have different return types, but this is not enough…