Some of the nuances of polymorphism remain foggy to me. Today it's covariant return types. I read a description of this feature and was surprised there is even a name for it - but apparently this behavior was illegal in previous versions. Or, maybe I'm missing something.
My understanding: covariant return types mean you can change the return type of an overridden method, as long as the new return type is derivative of the original return type. Is that it, or am I missing something about this feature? Here's my example:
[ February 03, 2008: Message edited by: Krep Lock ]
Joined: Jul 11, 2001
No, you aren't missing anything. And yes, it was introduced with Java 5.
Covariant return types are possible because they don't violate Liskov's Substitution Principle.
Interestingly, the JVM always supported them, it was only the language specification (and the compiler, consequently) that needed to be changed for this feature.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus