title: java how to avoid duplicate in recursion
body: <p>i'm trying to search synonym(which i declare as 'synset') recursively. Unfortunately, there are duplicate of synonym. For example: when i search the word student, the output will be like this:</p>
  
  <pre>
  Search word: student
  
  Synset 0: pupil
    Synset 0: student
      Synset 0: pupil
      .
      .
      .
    Synset 1: educatee
    Synset 2: schoolchild
  Synset 1: educatee
  Synset 2: scholar
  Synset 3: bookman
  </pre>
  
  <p>I want to store all the output into database and I do not need the duplicate output.This is part of my code that consist recursive function. Hope anyone can help me..Thanks</p>
  
  <p><pre>
  public String printSynset(String word)
      {
          //call wordnet library<br>
          RiWordnet wordnet = new RiWordnet();
          //call stemmer method
          PorterStemmer s = new PorterStemmer();</p>
  
  <code>    Vector&lt;String&gt; synsetVec = new Vector&lt;String&gt;();
      String[] synset = wordnet.getAllSynsets(word, "n");
  
      for (int k=0; k&lt;synset.length; k++)
      {
          synsetVec.add(synset[k]);
  
          if (!synsetVec.isEmpty())
          {
              for (int j = 0; j &lt; synsetVec.size();) 
              {   
                  GUIsynonymTA.append("\n");
                  GUIsynonymTA.append("   No." + j + ": " + (s.Stem(synsetVec.get(j))));
                  GUIsynonymTA.append("\n");
  
                  return printSynset(synsetVec.get(j));
              }
          }
  
          else if (synsetVec.isEmpty())
              return word;
  
      }
      return word;
  }//end printSynset()
  </code></pre>