Package edu.pdx.cs410J.j2se15
Class CovariantReturns
java.lang.Object
edu.pdx.cs410J.j2se15.CovariantReturns
This class demonstrates covariant returns in JDK 1.5. The
Java compiler allows an overriding method to change the method's
return type to be a subclass of the overriden method's return
type. However, you have to be extra careful when using covariant
returns with legacy code. If someone else overrides a method and
doesn't change the return type, their code will not compile.
- Since:
- Winter 2004
- Author:
- David Whitlock
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
An animal that can be cloned.(package private) static class
(package private) static class
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
CovariantReturns
public CovariantReturns()
-
-
Method Details
-
main
A main class that clones some animals. Note that we don't need to cast the result of theclone
method.
-