See which of your colleagues or former colleagues are already on Java Link: Check out the Contact Finder
News »Browse Articles » Using Generics to Store Specific Type of Objects in a HashMap
0
Vote Vote

Using Generics to Store Specific Type of Objects in a HashMap

Views 1 Views    Comments 0 Comments    Share Share    Posted by Balamurali 15-11-2010  
This example shows how to use generics to store objects in a HashMap. Before the time of generics,
one could also store specific objects in a Map but it could only be declared to contain Object instances,
without specifying what kind of objects.
And since values in a Map is stored in key / value pairs, the key was also regarded as an Object instance
The HashMap was then declared like this :
HashMap persons = new HashMap();
0
Vote  Vote
Enter your comment:
No Comments For This News

Search News

What's the News?

Post a link to something interesting from another site, or submit your own original writing for the Java community to read.

Most Popular News

Most Recent User Submitted News