NoSuchElementException While using Collections.min(List, Comparator) when List is not empty
<p>I am getting NoSuchElementException while using Collections.min, I have read other related questions too on the site, and learned that one gets this exception if the list or collection used is empty. But I have checked debugging the code, the list has values, still I am getting the exception. </p>

<pre><code>public Date getNewDate(List&lt;MyClass&gt; list1){

    Comparator&lt;MyClass&gt; startDate = new Comparator&lt;MyClass&gt;() {
        @Override
        public int compare(MyClass date1, MyClass date2) {
            return date1.getStartDate().compareTo(date2.getStartDate());
        }
    };

    return Collections.min(list1, startDate).getStartDate();
}
</code></pre>