Why polymorphism does not help and we need Generics? - Explained

Опубликовано: 25 Март 2026
на канале: java9s
9,590
169

Why we cannot use super types which can refer to some subtypes so that we can keep the classes Generics? The answer is that using Super types or Object as reference does not help. There will be issues with type casting and it is not an effective way to make code generic and reusable.
This is the reason why generics were introduced and they are extremely helpful in defining the reusable chunks of code.
In this video i gave a real world example to explain why we need generics in java