divide a list inside a nested list state-wise in java

2020-02-14 java list nested-lists

I have a nested list, for example:

[
       [ {roleid : 1, name: keer, state: karnataka},
         {roleid: 1, name: swathi, state:karnataka},
         {roleid : 1, name: joy, state: delhi}],
       [ {roleid : 2, name: E, state: karnataka},
         {roleid: 2, name: F, state:karnataka  },
         {roleid : 2, name: G, state: delhi}],
       [{roleid : 3, name: A, state: karnataka},
         {roleid: 3, name: B, state:karnataka},
         {roleid : 3, name: C, state: delhi} ]
] 

I have to get count of people in each state under each list. The output should be:

[roleid = 1, state = karnataka , count= 2]
[roleid = 2, state = delhi , count =1]

Answers

Related