13 Java Fundamentals | Overloaded Methods in Java | By Dummy for Dummies
INTRODUCTION It is not necessary that different methods must have different names. Methods are actually recognized by signature rather than just name. Signature of method includes name of method and it's parameters in which they recieve arguments. So you can have methods by same names yet they will receive different arguments and perform different functions. METHOD OVERLOADING Imagine the boss monkey sometime needs to add 2 numbers, while sometime it needs to add 3 numbers but the different number of arguments passed cannot be recieved by the same method. In that case you can create another method by same name and set it to recieve the desired numbers of arguments. As I said methods are recognized by signature rather than just names, so even though two methods have same name, if they receive different numbers or different types (datatype) of arguments they are considered different and java treat them as completely different methods. Here is a demonstration: public class Main { ...