I know there are classes like hashset that can remove duplicates but I doubt I can apply it to my case.
I have a list of dates, separated into month and day respectively.
private static List<MonthDay> Dates() {
List<MonthDay> dates = new ArrayList <MonthDay>();
dates.add(MonthDay.of(JAN, 1));
dates.add(MonthDay.of(JAN, 2));
dates.add(MonthDay.of(FEB, 3));
dates.add(MonthDay.of(MAR, 1));
return dates;
}
I've also created a method to return lists of specified dates.
private static List<MonthDay> Month(Month month) {
List<MonthDay> monthList = new ArrayList<>();
for (MonthDay m : Dates()) {
if (m.getMonth().equals(month)) {
monthList.add(m);
}
}
return monthList;
}
Now, I want to have a method to check whether my month is unique or not, and then return a <monthday> list of the dates containing the unique months.
e.g. FEB and MAR are unique months in the list, so the output I should get is [--02-03, --03-01]
How do I go about doing so?