Skip to content
Advertisement

Java remove dupplicate attribute in List

I have list of message, class Message have 2 attribute:
The following code below:

JavaScript
JavaScript

I want to remove duplicate message from list but must keep the message with the longest time in List
Input

JavaScript


Expect result

JavaScript

Advertisement

Answer

JavaScript

This will solve your issue.

P.S – plz go through basic data structures available in Java and their use cases.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement