title: Implementing Comparable interface produces "UnsupportedOperationException : ListIterator does not support set" error
body: <p>What I'm trying to do is to sort an arraylist of objects by a property (Integer) in Java.</p>
  
  <p>I've found several posting about using Comparable/Comparator for this perpose, but none of them seem to be related to "java.lang.UnsupportedOperationException" error. So, I'm writing a question here.</p>
  
  <p>I followed <a href="http://www.mkyong.com/java/java-object-sorting-example-comparable-and-comparator/" rel="nofollow">this page</a>, and have been trying to use Comparable interface.</p>
  
  <p>Here is part of my coding</p>
  
  <pre><code>public class Word implements Comparable&lt;Word&gt;{
  
  private String wordName;
  private int number;
  
   // There are only simple constructers, getters and setters 
  
  @Override
  public int compareTo(Word word) {
      int compareNumber = ((Word) word).getNumber();
      return compareNumber - this.number;
  
      }
  }
  </code></pre>
  
  <p>The main method is like this.</p>
  
  <pre><code>public static void main(String[] args) {
      //There are some irrelevant methods and fields
  
      List newWordList = new ArrayList&lt;&gt;();
  
      for (String wordName : WordList) {
          //WordList is of List&lt;String&gt;, containing several "wordName" (i.e. string values)
  
          //Get how many duplicate "wordName" inside the list
          int number = Collections.frequency(WordList, wordName);            
          Word word = new Word(wordName, number);
          newWordList.add(word);
      }
  
      List noDupList = SetUniqueList.setUniqueList(newWordList);
      Collections.sort(noDupList, new Comparator&lt;Word&gt;() {
          @Override public int compare(Word w1, Word w2) {
              return w2.getNumber() - w1.getNumber();
          }
      });
  
  }
  </code></pre>
  
  <p>Then, this produces "java.lang.UnsupportedOperationException: ListIterator does not support set".</p>
  
  <p>I'm confused particularly about "ListIterator", since I don't use this class nor do I use Set class either.</p>
  
  <p>I would appreciate if you would give any insight.</p>