Site hosted by Angelfire.com: Build your free website today!
 

Method Overloading

Java supports method name overloading so that multiple methods can share the same name.

class DataRenderer {
    void draw(String s) {
        . . .
    }
    void draw(int i) {
        . . .
    }
    void draw(float f) {
        . . .
    }
}
  • You do not have to think of a new name for each method, for example, drawString, drawInteger, drawFloat, and so on.

  • Overloaded methods are differentiated by the number and type of the arguments passed into the method (method signature).