Hi I want to use lambda in java to remove duplicate elements in a list . Define if it is duplicate will be by a custom function Let's suppose we have these objects:
Object1(id:1 , name:"SEVERO" , grade:"A")
Object2(id:2 , name:"SEVERO" , grade:"B")
Object3(id:3 , name:"LUCY" , grade:"A")
Object4(id:4 , name:"LUCY" , grade:"A")
Object5(id:5 , name:"PAULA" , grade:"A")
Expected results:
Object2(id:2 , name:"SEVERO" , grade:"B")
Object3(id:3 , name:"LUCY" , grade:"A")
Object5(id:5 , name:"PAULA" , grade:"A")
So basically if there are objects with same name, I only want to keep one of them. The one that will be kept is the one with the highest grade (order of grades: A->B->C), in case there is a tie based on the grade, any of the objects can be kept , there is not preference.
How can I do this using java lambda?