Streams – distinct() operation
class Test { public static void main(String[] args) { List<String> names = new ArrayList<>(Arrays.asList(“Megan”, “John”, “Melissa”, “Tom”, “John”, “Megan”, “Steve”, “Tom”)); List<String> uniqueNames = names.stream() .distinct() .collect(Collectors.toList()); System.out.println(uniqueNames); } } Output: [Megan, John, Melissa, Tom, Steve] class User { private String name; private String username; private String membershipType; private String address; public User(String name, String…
Read More Streams – distinct() operation