Java Covariant Return Types - The Coding Shala
Home >> Learn Java >> Java Covariant Return Types
Java Covariant Return Types
In Java 5.0 onward it is possible to override a method by changing the return type. The child's return type should be sub-type of parent's return type.
Covariant return type refers to the return type of an overriding method. It works only for non-primitive return types.
Example of Covariant Return Type in Java
The following is a simple example of the covariant return type is java:
we will see one more example of method overriding that explains covariant return types:
Other Posts You May Like