I would like to know what are the best ways to split a sheet into smaller sheets according to the values in the object, preferably within the framework of Java SE 7 . For example, there is an ArrayList personList containing 1000 objects of type Person, sorted by Person.name. It is necessary to break the personList, into other sheets by the same person names. So far, apart from such things, nothing came to mind:
ArrayList<Person> personList = new ArrayList<Person>(); ArrayList<ArrayList<Person>> allLists = new ArrayList<ArrayList<Person>>(); ArrayList<Person> arr2 = new ArrayList<Person>(); String name = personList.get(0).getName(); arr2.add(personList.get(0)); for (int i = 1; i < personList.size(); i++) { if(!name.equals(personList.get(i).getName())) { name = personList.get(i).getName(); allLists.add(arr2); arr2 = new ArrayList<Person>(); } if(personList.size() == i+1) { arr2.add(personList.get(i)); allLists.add(arr2); break; } arr2.add(personList.get(i)); } 
