Method Overloading in JAVA
Method Overloading
Method Overloading Concept is used in JAVA when there are many methods inside the source code with the same name in the same class.
A JAVA code will have multiple methods with the same name while its parameters are different.
We can do method overloading by changing the parameter.
It is known as Method Signature.
So multiple methods can have same name with different parameters.
We should pass relevent agruments to the parameter when the method is being called.
Consider the following methods.
void one() {
}
void one(String a) {
}
void one(int x) {
}
void one(float x,float y) {
}
We can see there are 4 methods with the same name but with different parameters.
Now you can call them by giving suitable arguments.
one ();
one ("hello world !");
one (567);
one (56.9,45.3);
Simply, this is the way of using many methods with the same name in a same JAVA class in programming.
I think you all are able to understand how to use Method Overloading Concept in JAVA.
See you in the next article.Until then Good Bye !
check these links for better understanding
Comments
Post a Comment