InterviewSolution
| 1. |
What Is Linkedhashmap? |
|
Answer» LinkedHashMap is also one of the implementation of the Map interface, apart from implementing Map interface LinkedHashMap also extends the HashMap class. So just like HashMap, LinkedHashMap also ALLOWS one null key and multiple null values. How it DIFFERS from other implementations of the Map interface like HashMap and TREEMAP is thatLinkedHashMap maintains the insertion order of the elements which means if we iterate a LinkedHashMap we'll get the keys in the order in which they were inserted in the Map. LinkedHashMap maintains a doubly-linked list RUNNING through all of its ENTRIES and that's how it maintains the iteration order. LinkedHashMap is also one of the implementation of the Map interface, apart from implementing Map interface LinkedHashMap also extends the HashMap class. So just like HashMap, LinkedHashMap also allows one null key and multiple null values. How it differs from other implementations of the Map interface like HashMap and TreeMap is thatLinkedHashMap maintains the insertion order of the elements which means if we iterate a LinkedHashMap we'll get the keys in the order in which they were inserted in the Map. LinkedHashMap maintains a doubly-linked list running through all of its entries and that's how it maintains the iteration order. |
|