I have Request class which is a parent class and AddressRequest class which extends Request.
public AddressRequest extends Request
{
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
I have the input data in the Request object. how can I set the userId to the same object by calling the setter method in the child class.
I downcasted the Request object to AddressRequest object and tried calling the setter method which is throwing CTE.
Request request= new AddressRequest ();
request=(AddressRequest )inputRequest;
request.setUserId("11");
How can i call the child method after downcasting object?