Home > Back-end >  Different collection calculate and merger
Different collection calculate and merger

Time:12-29

Met you, consult a Java collection problem
List 1
Id, type, num
1, a, 10
2, b, 5
3, a, 5

List2
Id, name, aid, bid, atype
1, apple, 1, 2, aa
2, bana, 2, 3, bb
3, apple,,, a1

# list1. Id=list2. Id

Plan to merge into the following
List3
Name, aid, bid, num
Apple, 1,2,15
Bana, 2,3,5
# num for a list of the same type num aggregation,
This should be how to do?

I only know may write
List3=addalll (list1)
List3=addalll (list2)?
Collect. Groupingby (listdto: : getname)?
  • Related