java - What is LinkedHashMap and what is it used for? -


when going through example code has listviews came linkedhashmap. linkedhashmap , can use , how? went through several articles did not understand fully. necessary when creating listview. connection between listviews , linkedhashmaps? thank you.

for simplicity, let understand difference between hashmap , linkedhashmap.

hashmap: gives output in random orders means there no proper sequence how have inserted values.

whereas

linkedhashmap: gives output in sequential order.

let see small example: hashmap

    // suppose have written program     .     .     // use hashmap     hashmap map = new hashmap();  // create object     map.put(1,"rohit");          // insert values     map.put(2,"rahul");     map.put(3,"ajay");      system.out.println("map=" +map); //print output using concatenation       //so output may in order can output may as:     map={3=ajay,2=rahul,1=rohit} 

but not case in linkedhashmap replace "hashmap" "linkedhashmap" in above code , see display output in sequential order 1=rohit displayed first others in sequence.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -