I have arrayList
ArrayList<Product> productList = new ArrayList<Product>();
productList = getProducts(); //Fetch the result from db
This list is stored in an ArrayList. The problem is that when I print its data, I obtain :
A, Arizona, 1980
B, Arizona, 1970
C, NewYork, 1980
D, NewYork, 1970
E, California, 1960
I want to convert to ArrayList to Map based on area:
Map<Integer, Map<String, List<Product>>>//Integer here is year and String here is manufacturingArea
The Product bean has the following structure :
class Product{
private String name;
private String manufacturingArea;
private int year;
/* Getters and setters*/
/* toString method */
}
I'd like to convert to map like this :
{1980= [Arizona,A], [NewYork,C]},
{1970= [NewYork,B],[NewYork,D]},
{1960= [California,E]}
how can I group the data by converting arraylist to map?