Map maintaining insert order of key-value pairs
Many time we want to maintain order of entries as it is inserted. HashMap does not satisfy this requirement. For all such requirement java collection framework has provided LinkedHashMap. Following example explains : 1: import java.util.*; 2: class MapTest 3: { 4: public static void main(String[] args) 5: { 6: System.out.println(" Using HashMap: "); 7: Map hashMap = new HashMap(); 8: hashMap.put(" One "," One "); 9: hashMap.put(" Two "," Two "); 10: hashMap.put(" Three "," Three "); 11: hashMap.put(" Four "," Four "); 12: hashMap.put(" Five "," Five "); 13: System.out.println(" Complete Map content : "+ hashMap.toString()); 14: System.out.println(" Iterating Key-Value: "); 15: Iterator itr = hashMap.keySet().iterator(); 16: while (itr.hasNext()){ 17: System.out.println(hashMap.get(itr.next()));...