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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.