E.13. Overloading Methods
Overloading a method means defining multiple methods in the same class, each with the same name, each of which accepts a different parameter list. In this example the Vehicle class extends the Car class. Let us assume that by default, the honk() method will make a honking sound one time.
class Car extends Vehicle { void honk() { // honk code goes here } void honk(int numberOfHonks) { // honk int number of times } }
Get Java™ for ColdFusion® Developers 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.