LinkedHashMapobject.put("Nokia Lumia price", new Integer(15000)) LinkedHashMapobject.put("Sony T2 Ultra price", new Integer(20000)) LinkedHashMapobject.put("Micromax canvas price", new Integer(9000)) LinkedHashMapobject.put("Samsung Grand quattro price ", new Integer(10000)) Step 2: Elements are entered using put() method Map linkedHashMapobject = new LinkedHashMap() Step 1: linkedHashMap object is created Let us discuss LinkedHashMap Implementation with the help of program, following program has been divided into 4 Steps that we will discuss one by one. This doubly-linked list maintains the iteration ordering, which is in general the order in which keys were added in the map.Įxample of LinkedHashMap Implementation : To attain this functionality all the entries(key and value) are linked to each other using doubly-linked list. As, HashMap does not maintains the insertion order, that is when we retrieve values from it we do not get that values in the same order we have entered in it. So, The functionality of maintaining the insertion is added into LinkedHashMap. LinkedHashMap is a type of Collection, which takes all the functionalities of HashMap class i.e. it stores our data in a pair such that each element has a key associated with it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |