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.
public Date getNewDate(List<MyClass> list1){
Comparator<MyClass> startDate = new Comparator<MyClass>() {
@Override
public int compare(MyClass date1, MyClass date2) {
return date1.getStartDate().compareTo(date2.getStartDate());
}
};
return Collections.min(list1, startDate).getStartDate();
}