title: Java - Printing occurrences of a number without duplicating
body: <p>I'm trying to display the following after prompting users for input:</p>
  
  <p><img src="https://i.stack.imgur.com/wXcNV.png" alt="enter image description here"></p>
  
  <p>Whereas this is my current input:</p>
  
  <p><img src="https://i.stack.imgur.com/RsA31.png" alt="enter image description here"></p>
  
  <p>As you can see, if I input a number twice, it is listed twice.</p>
  
  <p>Any suggestions on what to do? This is my code:</p>
  
  <pre><code>public static void main(String[] args){
      Scanner input = new Scanner(System.in);
  
      ArrayList&lt;Integer&gt; Digits = new ArrayList&lt;&gt;();
      System.out.print("Enter digits: ");
      int value;
  
      do {
          value = input.nextInt();
          if (value &gt; 1 &amp;&amp; value &lt; 101) 
              Digits.add(value);
          } while (value != 0);
  
      java.util.Collections.sort(Digits);
      Set&lt;Integer&gt; uniqueInputs = new HashSet&lt;Integer&gt;(Digits);
      for (int i = 0; i &lt; Digits.size(); i++) {
          System.out.println(Digits.get(i) + " - " + Collections.frequency(Digits, Digits.get(i)) + " times");
      }
  </code></pre>