【发布时间】:2014-01-07 17:58:21
【问题描述】:
我有接口:
interface Identifable<T extends Serializable> {
T getID();
}
和实现这个的类:
public class Cat implements Identifable<Long> {
public Long getID(){...};
}
一切正常。迄今为止。现在我想创建GenericDAO,为什么我不能创建这个?:
public abstract GenericDAO<T extends Identifable<S>> {
T getByID(S id);
}
我只能这样声明我的 GenericDAO:
public abstract GenericDAO<T extends Identifable, S> {
T getById(S id);
}
并完成课程:
public CatDAO extends GenericDAO<Cat, Long> {
Cat getById(Long id);
}
但我认为它没用,因为我重复信息。我已经声明了,Cat 实现了 Identifable
【问题讨论】: