Incompatible return type for subclasses in Requirements in Overriding and Hiding of JLS

quoting from JLS

If a method declaration d1 with return type R1 overrides or hides the declaration of another method d2 with return type R2, then d1 must be return-type substitutable for d2, or a compile-time error occurs. Furthermore, if R1 is not a subtype of R2, an unchecked warning must be issued (unless suppressed (§9.6.1.5)). A method declaration must not have a throws clause that conflicts (§8.4.6) with that of any method that it overrides or hides; otherwise, a compile-time error occurs.

Doesn't the bold sentence contradict the first part of the paragraph.

I can read below in JLS that this applies for generic returns for example

List<String> return type being overrided by List return type but still that sentence in the JLS doesn't exclude this to only this situation, can you clarify me if there is another situation where that sentence applies?

Related Articles
You Might Also Like