Originally posted by colton peterson:
That would be a case of overloading. If you wanted overiding everything would have to be the same.
Well not anymore.
Java 5.0 introduced a new feature (can't think of the name*), which allows you to downcast the return type - you can return any type as long as it is a subclass of the return type of the original method.
This can be very useful for cloning:
The reason this is allowed is because any calling class expect something of the original method's type (Object in the example). Any subclass will respect that expectation.
* Just remembered: it's called covariant return.
[ November 22, 2007: Message edited by: Rob Prime ]