Overloading Methods

Earlier in the chapter, polymorphism was mentioned as an important feature of object-oriented programming languages. Although polymorphism is not unique to object-oriented programming, it tends to provide the greatest benefit in an object-oriented setting. Method overloading is the primary way in which polymorphism is implemented in Java. Method overloading consists of using the same method name with different arguments and return types within the same class. The only restriction placed on overloading is that two methods cannot have the same name and the same argument list. In other words, at least one argument must be different. Argument lists differ if they are a different sequence of types. The argument names do not matter. ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.