class overloadering in simple code example

Example 1: 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)

Example 2: what is overloading

Method Overloading 
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.
1) Method Overloading occurs with in the same
class
2) Since it involves with only one class inheritance
is not involved.
3)In overloading return type need not be the same 
4) Parameters must be different when we do
overloading
5) Static polymorphism can be acheived using
method overloading
6) In overloading one method can’t hide the
another

Tags:

Misc Example