Why use generics?
There are mainly two reasons to use generics. These are:- Performance – Collections that store objects use Boxing and Unboxing on data types. This uses a significant amount of overhead, which can give a performance hit. By using generics instead, this performance hit is removed.
- Type safety – There is no strong type information at compile time as to what is stored in the collection.