![]() |
VOOZH | about |
LinkedHashMap is a predefined class in Java that is similar to HashMap, contains key and its respective value unlike HashMap, In LinkedHashMap insertion order is preserved. We need to print the value of the hash map which is linked with its key. We have to iterate through each Key present in our LinkedHashMap and print its respective value by using a for loop.
Example:
Input: Key- 2 : Value-5 Key- 4 : Value-3 Key- 1 : Value-10 Key- 3 : Value-12 Key- 5 : Value-6 Output: 5, 3, 10, 12, 6
Algorithm:
Example:
5, 3, 10, 12, 6,
Time complexity: O(n).