elibraryportal Logo

Method Overloading in Java | Example

→ In method overloading, Same method, different Parameters is known as Method Overloading.

Syntax :-


Example :-

Output

Method Overloading in Java | Example

Advantage of method overloading

  • We don't have to create and remember different names for functions doing the same thing
  • It increases the readability of the program.

Different ways to overload the method

There are two ways to overload the method in java

  1. By changing of Parameter or Argument
  2. By changing the Data Type

1) By changing of Parameter or Argument

Example :-

Output

Method Overloading in Java | Example

2) By changing the Data Type

Example1 :-

Output

Method Overloading in Java | Example

Example2 :-

Output

Method Overloading in Java | Example

Example3 :-

Output

Method Overloading in Java | Example