Folks, i've been trying :roll: to get to grips with the concept of overloaded methods, and have been following an example from a book (Sams Teach Yourself
Java in 21 Days).
Well, thing is, I think I've followed what's been going on, but I have a few queries regarding the code.
The code is listed below.
This program starts with a simple class definition for a class called MyRect, which defines a rectangular shape with four instance variables to define the upper-left and lower-right corners of the rectangle x1, y1, x2 and y2.
A buildRect() instance method sets the variables to their correct values.
First question:-
Why do we need to use the "this" keyword? Afterall, the variables in the method signature take care of which values are to be used, surely??
Next thing - regarding the first overloaded method.
Basically, how does this work?? I mean, the signature bares very little correlation to the standard use of a signature. Is it something to do with the use of the Point object??
Last point - a very silly question really. Why bother having overloaded methods - I mean, couldn't we just change the name of the method we wanted to re-implement??

[ May 06, 2003: Message edited by: Steve Jensen ]