DEV Community

Ratik Mahajan
Ratik Mahajan

Posted on

2 1

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)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay