title: How to count distinct Strings in ArrayList without using Set?
body: <p>How do you count the number of distinct Strings in an <code>ArrayList</code> without using the Set data structure in the Java libraries?</p>
  
  <p>I made two ArrayLists, one stored and one empty and want to store the empty one with distinct Strings. What am I doing wrongly?</p>
  
  <pre><code>public void distinctCount (WordStream words) {
  ArrayList&lt;String&gt; loaded = new ArrayList&lt;String&gt;();
    ArrayList&lt;String&gt; empty = new ArrayList&lt;String&gt;();
    int count = 0;
  
    // Fill loaded with word stream
    for(String i : words) {
      loaded.add(i);
    }
  
    // Fill empty with loaded
    // Catch collisions
    for(int i = 0; i &lt; loaded.size(); i++) {
      if(loaded.get(i) != empty.get(i)) {
        empty.add(loaded.get(i));
      }
    }
    return empty.size();
  }
  </code></pre>