考虑以下情况:
public abstract class Vegetable {};
public class Tomato extends Vegetable {};
public class Cucumber extends Vegetable {};
public class Orange {};
关键是 - 我希望我HashSet只存储扩展的东西Vegetable,我该怎么做?这个应该很简单。。
..Set <? extends Vegetable> () hs = new HashSet <? extends Vegetable> ();但当然不是一个有效的结构,Java希望我指定Set我想要什么类型 -Tomato或者Cucumber,如果我只想要任何蔬菜怎么办?
我宁愿不使用任何演员表...