title: Find duplicates in array list using Map<String, Integer> with input order
body: <p>Hi everyone I am trying to print all the duplicated elements, this works fine but the outputs are not in order (either from user input or from the text file).
  I want to print all elements with order (duplicates are not printed). How do I do that?
  The codes are from this <a href="https://stackoverflow.com/questions/12947926/find-the-duplicate-elements-in-arraylist-and-display">Find the duplicate elements in arraylist and display</a>
  Thanks @Cory Kendall for the codes.</p>
  
  <p>**********updated question: the code now works perfect with LinkedHashMap. Now I want the outputs to be printed with number bullets (ie, 1. name1 = 2 ) incrementally. Thanks</p>
  
  <pre><code>List&lt;String&gt; strings = new ArrayList&lt;String&gt;();
  // suppose datas are entered by user incrementally or from a text files.
  
  Map&lt;String, Integer&gt; counts = new HashMap&lt;String, Integer&gt;();
  
  for (String str : strings) {
      if (counts.containsKey(str)) {
          counts.put(str, counts.get(str) + 1);
      } else {
          counts.put(str, 1);
      }
  }
  
  for (Map.Entry&lt;String, Integer&gt; entry : counts.entrySet()) {
      System.out.println(entry.getKey() + " = " + entry.getValue());
  }
  </code></pre>