Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下
public abstract class BaseImpl<T>{ public T getObject(); }
现在我想像这样扩展类
public class PersonImpl{ //Works public Object getObject(){} //But I would like it to be like this public Person getObject(){} }
我对泛型不是很好,但这可能吗?这里有更好的模式吗?
扩展 的通用版本BaseImpl,提供您想要的类型:
BaseImpl
public class PersonImpl extends BaseImpl<Person> {