title: how to remove duplicate words from an array in java
body: <p>I am reading a file then calling a string[] method that breaks the line up into individual words, adds each word to an array of unique words (no duplicate words), and returns the array of unique words.</p>
  
  <p>I cannot figure out how to only print each word once but here is what I have so far.</p>
  
  <pre><code>static public String[ ] sortUnique( String [ ] unique, int count)
  {
      String temp;
      for(int i = 1; i &lt; count; i++) {
          temp = unique[i].replaceAll("([a-z]+)[,.?]*", "$1");;
          int j;
          for(j = i - 1; j&gt;= 0 &amp;&amp; (temp.compareToIgnoreCase(unique[j]) &lt; 0);j--) {
              unique[j+1] = unique[j];
          }
          unique[j+1] = temp;
      }
      return unique;
  }
  </code></pre>
  
  <p>And here is the data file. </p>
  
  <pre><code>    Is this a dagger which I see before me,
      The handle toward my hand? Come, let me clutch thee.
      I have thee not, and yet I see thee still.
      Art thou not, fatal vision, sensible
      To feeling as to sight? Or art thou but
      A dagger of the mind, a false creation,
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>