While I was developing class architecture to meet my needs, I came across this thing. I have an abstract class in which there are some methods inside it that must be implemented by the subclass, but in the subclass I found that I need to implement with a signature that inherits from the first.
To show you what I mean:
// 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 { }
Is there any way to do this? I do not know if this is possible with the help of the general. Thank you so much.
source share