I don't know what you mean by "how to link ArrayList and HashMap". Do you mean you want to know what the similarities and differences between these two are?
ArrayList and HashMap are both standard Java collection classes, but they have a different structure and a different purpose. An ArrayList is a an ordered sequence (a list) of objects backed by an array, and a HashMap is an associative array - a data structure that maps keys to values.
If you put the same objects into the HashMap, then you can retrieve them.
You appear to have misunderstood the two. It is a bit like asking whether you can use a boat or a bicycle. The answer is yes, but where boats work bicycles don't, and vice versa
You can put your ArrayList elements in a Map as follows:
The KeyType is usually something immutable like String, Integer or Long. The name of any object is often used. For instance:
Vice versa you have two options:
1) store map.entrySet() in the List
2) ignore the keys and store map.values() in the List.