JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

LinkedHashMap in java with example

LinkedHashMap is same as HashMap except that it maintains insertion order.
Some points about LinkedHashMap
  1. LinkedHashMap implements Map interface and extends HashMap class.
  2. LinkedHashMap maintains insertion order, so when you will be able to access elements in the order they were inserted like ArrayList.
  3. LinkedHashMap maintains doubly Linked list to maintain insertion order.

Example:

LinkedHashMapMain.java
If you may iterate LinkedHashMap in multiple ways.
When you run above program, you will get below output:

.