I have implemented a chat function in my app and it\'s working fine, only problem is that now I want the chats to be ordered by timestamp, so that the newest ones c
You can simply use Java8 feature to compare the element as below:
List unique = list.stream().collect(collectingAndThen(toCollection(() -> new TreeSet<>(comparing(ChatList::getTimestamp))),ArrayList::new));
unique.forEach((k) -> System.out.println(k.getTimestamp()));