我有一个名为Man. 在这个接口中,我有一个getList()返回类型 T 列表的方法(依赖于实现接口的类)。我有 3 个实现Man: small、normal和big. 每个类都有方法getList()tart 返回一个列表small或列表normal或列表big。
interface Man<T>{
List<T>getList();
}
class small : Man<small>{
List<small> getList(){
return new List<small>();
}
}
class normal : Man<normal>{
List<normal> getList(){
return new List<normal>();
}
}
class big : Man<big>{
List<big> getList(){
return new List<big>();
}
}
现在我有了类:Home 它包含一个参数bed,它是Man.
Bed可以有多种类型:small, normal, big. 如何声明类型参数bed?
class Home{
Man bed<> // what i must insert between '<' and '>'??
}