What is an overload of a method: method overloading is a means for a class to handle different types of data in a uniform manner. Multiple functions with the same name exist at the same time, with different number/types of parameters. Overloaded overloading is a representation of polymorphism in a class. Simply put, the overloading of a method is a multiple implementation of the same function of a class. Which method to use depends on the parameters passed at the time of invocation Assuming that we have a requirement to write a method to receive two parameters and return the larger number. That's what we're going to write.//If the parameter is of type int getmaxint (int a, int b) {if (a > B) {return A;} else {return B;} } //If the parameter is a float type of public float getmaxfloat (float A, float b) {if (a > B) {return A;} Else{return b;}} Getmaxint is called when we want to compare the larger int data. To get a larger float, call getmaxfloat. Can you define two method names as well, such as uniformly defined as a Getmax method name? Because two methods use the same method name, but because of their return data type, and the type of the parameter is different, so the Java compiler can identify you exactly is called which, this is a polymorphic embodiment of public int getmax (int A, int b) {if (a > B) {return A;} else {return B;} } //If the parameter is a float type of public float getmax (float A, float b) {if (a > B) {return A;} Else{return b;}} Method overload precautions: 1. The parameter type of the method, the number of parameters (the parameter name does not count), the order of at least one of the different 2. The returned data type can be 3 different. The modifier of the method can be different if just the return data type is not the same can you make an overload? For example: public float Getmax (float A, double) { if (a > B) {}return (float) A;} else {return (float) b;} public Double Getmax (float A, float b{ if (a > B) {}return A;} else {return B;} The answer is: If just the return data type is different and does not constitute an overload if just the access modifier is not the same, can you make an overload? The answer is: no
Java method overloading