I have list of Object . I want to compare elements of the list and perform operation if the are equal on a condition.
class A{ String abc; int pqr; }
I have List items with me
"items": [ { "pqr": 2, "abc": 1994 }, { "pqr": 2, "abc": 1994 }, { "pqr": 1, "abc": 64 } ]
Now i want my output list as
"items": [ { "pqr": 4, "abc": 1994 }, { "pqr": 1, "abc": 64 } ]
i/e comparing th elements on the basis of abc and if its is same add its pqr value and remove the duplicate.
How can i do this using stream or efficiently?