The compiler does not consider the return type when differentiating methods, so you cannot declare two methods with the same signature, even if they have a different return type.
If you know about the execution of the function, then you will know that when we call the function that is executed by the part of the definition, and finally we require the return statement, so we can say that the return comes after the completion of the whole function, which is why there are two or more functions with the same name and with the same type are not. arguments, and then during a call of how the compiler will know which one will be called, because the name and parameters of the function are the same. During the call, firstly, all the tricks will be focused on the arguments and the name of the function, and after completing the definition of the function, finally, we are dealing with the return statement.
A compile-time error is better than a run-time error. Thus, the java compiler displays a compiler time error if you declare the same method having the same parameters.
LearnAndHelp Jul 17 '17 at 7:45 2017-07-17 07:45
source share