当我开发一个满足我需求的类架构时,我遇到了这种情况.我有一个抽象类,其中包含一些必须由子类实现的方法,但在子类中,我发现我需要实现从第一个继承的签名.
告诉你我的意思:
// person class
public abstract class Person
{
protected void abstract workWith(Object o) throws Exception;
}
//developer class
public class Developer extends Person
{// i want to implement this method with Computer parametre instead of Object and throws `//DeveloperException instead of Exception`
protected void workWith(Computer o) throws DeveloperException
{
//some code here lol install linux ide server and stuff
}
}
// exception class
public class DeveloperException extends Exception
{
}
Run Code Online (Sandbox Code Playgroud)
有什么办法吗?我不知道是否可以使用泛型.非常感谢.