Why Generics

This lesson introduces the concept of generics in Java.

We'll cover the following...

Question # 1

When were generics introduced in the Java language?

Generics in Java were released with J2SE 1.5 in 2004. Later on, J2SE 1.5 was renamed to Java SE 5.0.

Question # 2

Why should we use generics in Java?

Generics help with the following use-cases

  • Enforcing stronger type checking at compile time for greater type-safety

  • Elimination of casts

  • Implementation of generic algorithms

Question # 3

...