要删除重复项,请使用
HashSet<String>:
public void printOwners() { for (String s : new HashSet<>(owners.values())) { System.out.println(s); }}或者使用Java 8
Stream和
distinct()方法:
public void printOwners() { owners.values().stream().distinct().forEach(System.out::println);}


