void (String[] args) { List<String> names = Arrays.asList("Bob", "Alice", "Bob", "Carol"); Set<String> uniqNames = new HashSet<>(names.size()); names.forEach(name -> uniqNames.add(makeNameUnique(name, uniqNames))); uniqNames.forEach(System.out::println); }