Relative Content

Tag Archive for javagenericstypesoverriding

Why must type parameters match for overriding Java methods?

Java methods are allowed to specify type parameters that may or may not be used to classify method parameters. Why are type params taken into account when matching method signatures (for the purpose of overriding)? Shouldn’t these unused params be thrown away? In other words, why doesn’t the below compile [in Java 21]?