What Are Generics In Java
My younger cousin asked me what “generics” are in Java. I thought about it for a while, and I realized that in order to give a proper explanation, the following topics need to be understood first:
- Runtime VS Compile Time errors
- Inheritance
- Polymorphism
1. Runtime VS Compile Time Errors
Compile Time Errors
In a modern IDE, such as Eclipse or IntelliJ, you have a compile-time error if your code is marked by a red line: