Thursday, 12 April 2018

Why Map is not child interface of Collection ?

Now a days in interview interviewer always ask questions related to Collection and map
And they also ask why map interface is not child of collection interface.

Here is very simple resion

Collection talks about individual object. in collection we can store only individual objects.
Where Map talks about storing  the object as key and value pairs. here key and value are two objects.

That's why Map doesn't extends the Collection interface.

No comments:

Post a Comment

session-per-request in hibernate

The most common pattern in a multi-user client/server application is session-per-request . In this model, a request from the client is sent...