I have a class:
public abstract class Response<T> {
private boolean isSucessfull;
private T data;
public Response() {
throw new IllegalArgumentException();
}
public Response(boolean isSucessfull, T data) {
this.isSucessfull = isSucessfull;
this.data = data;
}
...
}
And other classes extend it with some specific types:
public class PlainResponse extends Response<byte[]>{
//
}
The problem occurs when I try to create an instance of PlainResponse: new PlainResponse(success, responseData)
constructor PlainResponse in class PlainResponse cannot be applied to given types;
required: no arguments
found: boolean,byte[]
As you can guess, I'm not an expert in java. But I've expected, that my class will use the constructor of it's super class.
How can I achieve it?
Thanks.
Responsein the first place. Seeing as it's impossible to actually call without raising an exception, you would be better off simply not defining it in the first place. Then the compiler can requirePlainResponsehave a constructor that calls the parent(boolean, T)constructor.