In my program I have an array list of type Program like this:
List<Program> programList= new ArrayList<Program>();
public class Program {
public String name;
public String date;
public Program(String name, String date) {
this.name = name;
this.date= date;
}
public String date getDate()
{
return date;
}
public String date setDate(String date)
{
this.date=date;
}
public String date getName()
{
return name;
}
public String date setName(String name)
{
this.name=name;
}
and in my activity i am adding items to the list
for(int i=0; i < 100; i++)
{
Program p= new Program("name","some date");
programList.add(p):
}
And I want to group items by date, like there are hundred items in list and many of them have same date, I want to make pairs with the date and the new lists of the items having same date.
First of all, your Program class should look like this:
If you have public fields like you had, its pointless to make getters and setters.
Anyhow, you could use HashMap for sorting programs by date: