摘自《Java思维》一书:
你的密码。考虑一下: Map<Person, List<? extends Pet>> petPeople = new HashMap<Person, List<? extends Pet>>(); 看起来您在重复自己,而且编译器 应该从另一个通用参数列表中找出其中一个。 唉,它 不能
你的密码。考虑一下:
Map<Person, List<? extends Pet>> petPeople = new HashMap<Person, List<? extends Pet>>();
看起来您在重复自己,而且编译器 应该从另一个通用参数列表中找出其中一个。 唉,它 不能
这是否意味着双方的显式类型规范都是由编译器强制执行的?
Map<Person, List<? extends Pet>> petPeople = new HashMap();
Map<Person, List<? extends Pet>> petPeople = new HashMap<>();