donaricano-btn

 Covariant Return type


- The covariant return type specifies that the return type may vary in the same direction as the subclass

- Since Java5, it is possible to override method by changing the return type if subclass overrides and method whose return type is Non-primitive


1. Example


- The return type of the get() of A class is A, but the return type of the get() of Test class is Test

- Both methods have different return type but it is overriding

'Back-End > Java_1' 카테고리의 다른 글

[Java] Instance initializer block  (0) 2016.09.07
[Java] Super keyword  (0) 2016.08.25
[Java] Overloading vs Overriding  (0) 2016.08.24
[Java] Method Overriding  (0) 2016.08.24
[Java] Aggregation in java  (0) 2016.08.23
블로그 이미지

리딩리드

,