java method overloading tutorial

Bodhak java method overloading tutorial in this topic we will learn about what is method overloading and it’s rules of method overloading. 

Method overloading is a programming concept when programmer declare two methods with same name but with different method signature i.e. change in argument list or change in type of argument.


java method overloading tutorial

the best example for method overloading is System.out.println(). This method is overloaded to accept all kinds of data types in Java i.e String, int, float, double and char.

Rules for overloading method:

1) Overloaded methods are bonded using static binding in java. Which occurs during compile time i.e. when you compile Java program. During the compilation process, the compiler bind method call to the actual method.

2) Overloaded methods are fast because they are bonded during compile time and no check or binding is required during runtime.

3) Most important rule of method overloading in Java is that two overloaded methods must have the different signature.

What does method signature mean in Java

1) The number of argument to a method is part of method signature.
2) Type of argument to a method is also part of method signature
3) Order of argument also forms part of method signature provided they are of different type.
4) return type of method is not part of the method signature in Java.

Next Page