更新:我的课是比这更复杂,我只是我被困在ArrayList的线摘要列表<Person>
我有以下类别:
class CatList {
List<Cat> cats = new ArrayList<Cat>();
}
和
class DogList {
List<Dog> dogs = new ArrayList<Dog>();
}
猫和狗都是数据类。
,但我想创建一个抽象类:
abstract class AnimalList {
List<???> animals;
AnimalList(Class animal) {
animals = new ArrayList<???>();
}
}
,这样我可以继承我的班
AnimalList CatList = new AnimalList(Cat);
AnimalList DogList = new AnimalList(Dog);
AnimalList CowList = new AnimalList(Cow);
希望这更有意义。我的问题是什么?位?
你是什么确切q题目了吧? – apnorton 2012-07-28 15:58:45