DEV Community

Ranuj Mahajan
Ranuj Mahajan

Posted on

What is generics in java?

Generics is used to make java type safe at compile time.
Generics to used to reduce boxing and autoboxing in java.
Generics is used where a class can take all the datatype in the java and store them. it is most commonly used in collections class.

class Example{
private T t1
public Example(T t1){
this.t1=t1
}
}

Top comments (0)