Map in Java & HashMap example | Java Collections # 9 | Java9s.com

preview_player
Показать описание
Map in java has a key and value pair objects.
The combination of this Key and value pair is called an ENTRY
With respect to Hierarchy, Map does not come under normal collections.
The reason is, All other collections like List, Set, Queue deal with elements where there is a single object at a level,
Where as Map works with key value pairs.
Due to this new model, Map needs differnt set of methods to work with entries and this is the reason why Map does not
extend collection interface.
One of the Important rules we got to remember while using Map based datastructures is that
- They do not allow duplicates as part of the keys.
In this video tutorial, i have explianed the concept of Map and its concrete implementation with HashMap Example
I have also mentiond about HashTable and how it is synchronized.

Java Collections Tutorials Playlist:

Complete Java Beginners Tutorials:

Multithreading in Java tutorial:

Spring 3 MVC Framework tutorials:

Spring Framework Tutorials:

Design Patterns in Java:

Complete Generics Tutorials playlist
Рекомендации по теме
Комментарии
Автор

Here is solution for first question... Thanks very much for your kind video its very


import java.util.Comparator;

public class CustomComparator implements Comparator<Employee> {

@Override
public int compare(Employee o1, Employee o2) {

// TODO Auto-generated method stub



int result =

if(result>0)
return -1;
else if(result < 1)
return 1;
return 0;

}*/
if(o1.getEmpid()%2==0 && o2.getEmpid()%2!=0)
{
return -1;
}
else if(o1.getEmpid()%2!=0 && o2.getEmpid()%2==0)
{
return 1;
}
return 0;


}
}

mayankparihar
Автор

Didn't know one could set ownerName from default constructor using:
ownerName= name.toString();
but apparently overriding toString method to one like this:
public String toString(){
return this.ownerName;
}

does the work. That was one more interesting thing learnt along learning how the HashMap works. Thanks.

marekbugiel
Автор

Your "download link " does not work.

turskyi
Автор

Hi which tool you are using for create this animation?

adityabhardwaj