Is there a way that I can pass a generic type to a generic class like
interface Wrapper<T, R> {}
interface Result<T, Wrapper<T, R>> {
R getResult();
}
Here Result takes Wrapper one of the type with type arguments T and R. getResult method in Result interface returns R.
What I did is below,
interface Result<T, W> {
<K> K getResult();
}
Is there a better way to do this in java.
Wrapperininterface Result<T, Wrapper<T, R>is not using your existingWrapper<T, R>interface. It's hiding it by declaring a new type parameter of the same name.