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.

Showing posts with label LinkedHashMap. Show all posts
Showing posts with label LinkedHashMap. Show all posts

LinkedHashMap in java with example

2:42 AM
LinkedHashMap is same as HashMap except that it maintains insertion order. Some points about LinkedHashMap LinkedHashMap implements Map interface and extends HashMap class. LinkedHashMap maintains insertion order, so when you will be able to access elements in the order they were inserted like ArrayList. LinkedHashMap maintains doubly Linked list to maintain insertion order. Example: LinkedHashMapMain.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29   package org . arpit . java2blog ;   import java . util . LinkedHashMap ;   public class LinkedHashMapMain {   public static void main ( String args [ ] ) { // LinkedHashMap with Country as key and capital as value // LinkedHashMap maintains insertion order   LinkedHashMap < String , String > countryCapitalMap = new LinkedHashMap < String , String > ( ) ;

.