Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

I know that Vector<int []> is a vector of integer arrays, and HashTable<String, Person> is a table of whose keys are strings and values Persons. 

What is the usage of Class<>?  The java class ‘Class’  takes the template name in eclipse. Why should I use it there? In general ‘Class’ object is used when you don’t have the information about an object fully. Why does eclipse make me specify which class the Class object will hold? 

Can anyone please explain the reason behind this?

1 Answer

0 votes
by (19.7k points)

The gentrified version of class Class lets you write things like,

Class<? extends Collection> someCollectionClass = someMethod();

It also makes the Class object you receive extends Collection and an instance of this class will be a Collection. 

If you want to learn more about Javathen go through this Java tutorial by Intellipaat for more insights.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 20, 2021 in Java by rahulnayar01123 (6.1k points)

Browse Categories

...