Search

Overloading of Methods

  • The Java programming language supports overloading methods, and Java can distinguish between methods with different method signatures. This means that methods within a class can have the same name if they have different parameter lists
  • You cannot declare more than one method with the same name and the same number and type of arguments, because the compiler cannot tell them apart.
  • The compiler does not consider return type when differentiating methods, so you cannot declare two methods with the same signature even if they have a different return type.


     

  • Note: 
    • Overloaded methods should be used sparingly, as they can make code much less readable.


 

No comments:

Post a Comment