Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interfaces and inheritance



On Jul 4, 2005, at 3:42 PM, Wilhelm Fitzpatrick wrote:


Glen, Todd... one source of confusing here is that what Todd is trying to do (return a type that is more narrow than is defined in the superclass/interface) *is not* allowed in Java up through version 1.4.x, but *is* allowed in Java 1.5.


The technical term for this is "covariant return types" and they were added to the language in 1.5.

In Java 1.4.x or earlier, the return types must match exactly, and you just have to cast what you get back if you are in a circumstance where you know it to be more specific.



That explains a lot. I was willing to believe that it was not allowed, but I couldn't think why it wouldn't be allowed. I guess the powers that be decided there was no good reason for it not to be disallowed.


Of course, now I have to decide if I want to deal with 1.5...

Thanks everyone!!!
Todd
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.