Section E.13. Overloading Methods

   

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     } } 

   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net