method overloading. code example

Example 1: what is method overloading and method overriding in Java?

Method overloading is providing two separate methods in a class with the same name but different arguments, while the method return type may or may not be different, which allows us to reuse the same method name.

Method overriding means defining a method in a child class that is already defined in the parent class with the same method signature, same name, arguments, and return type

Example 2: What's method overloading

Overloading mean same method name and different parameter, 
it can happen in same class. it's a feature that 
allows us to have more than one method with same name.

Example: sort method of Arrays class
Arrays.sort(int[] arr)
Arrays.sort(String[] arr)
....
Method overloading improves the reusability and readability. 
and it's easy to remember 
(one method name instead of remembering multiple method names)

Tags:

Cpp Example