In my program I have an array list containing product objects in it. I want to remove duplicated product objects from it. Is there any efficient way other than looping over each element and compare them.
just add all element into set. it wont allow duplicate values
List<Product> list=new ArrayList<>();
Set<Product> set=new HashSet<>();
set.addAll(list);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With