我正在關注emaze功能異常以便從arraylist中進行分組。在下面的代碼中,我可以從地圖中進行分組。控制檯顯示分組元素。我需要將它們添加到數組列表中。從arraylist中獲取組列表
例如,回報裏德有120個元素,但分組地圖包含三個組,每個元素爲40個元素。
List<LoanRepaymentSchedule> repay = loanService
.getLoanRepaymentScheduleById(groupLoan.getLoanId());
Map<Integer, List<LoanRepaymentSchedule>> map = Groups.groupBy(
repay, new Pluck<Integer, LoanRepaymentSchedule>(
LoanRepaymentSchedule.class, "memberCount"));
System.out.println ("map.keySet().size() "+map.keySet().iterator());
for (Integer key : map.keySet()) {
List<LoanRepaymentSchedule> pro = map.get(key);
System.out.println("Element-******* "+pro.size());
System.out.println("Element-******* "+pro.get(0));
}
如何保存在象列表1,list2中,項目list3單獨的數組列表3個分組元素。
償還列表如下,
id 1 val 5
id 1 val 6
id 1 val 1
id 1 val 5
id 1 val 6
id 1 val 1
我需要列表1作爲
id 1 val 5
id 1 val 5
列表2作爲
id 1 val 6
id 1 val 6
列表1作爲
id 3 val 1
id 1 val 1
你需要什麼列表(1,2,3)? –
瞭解id是關鍵嗎?和5或6是pro.get(0);? –
你到底需要什麼?您已在地圖中存儲了不同的列表。這些列表不包含你想要的東西嗎? – Eran