Covariant return types

After today’s lecture of “Effective Java” from Joshua Bloch, I can share some knowledge! Looking at the previous post about Recursive Builder Pattern, You may see interesting pattern – self() method. The idea is, to override self()from an abstract/superclass and change its return type to the current type. Current means, that it is the type of the child class, which overrides the method. Well, that is the simplified definition of covariant return types in JAVA.

Facebook Comments