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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -