Reputation: 478
I have a generic interface Service
:
public interface Service {
public <T> T callService(T request);
}
I want to modify the callService
method such that it can accept a generic parameter and return an instance of a different generic return type. How do I do that, either with the above declaration or by modifying it?
Upvotes: 0
Views: 74
Reputation: 1374
A generic is defined in the same way you have that example there, just have a placeholder for the type name. If you are looking to define it to have a generic input parameter type and a different generic return type then you can comma separate them.
public <T, R> R callService(T request);
Upvotes: 3