java - Generic method return super type of type param and method parameter type param -
I want to type super the ultimate of the ultimate type of one type and the ultimate type of the ultimate one.
This compiled:
import java.util.List; Interface foo & lt; A & gt; {& Lt; R, B expanded R & gt; & Lt; R & gt; Example 1 (list & lt; B & gt; entity); & Lt; R & gt; & Lt; R & gt; Example 2 (list increments unit); } But it does not apply that R must also be A's super. How do I do that?
Actually, I want to do something that is expressed in these:
But they do not compile.
It has two objectives:
- I want to be able to assign results to both A and B, to any super class.
- In the implementation of this method, I need a result type in which both A and B can be included, then the first examples compiling will not work because they will not keep A in the result.
I think you need to name the type parameter at the class level:
import java.util.List; Interface foo & lt; Base, one base and GT; {& Lt; B. expanded base & gt; & Lt; Base & gt; Example 1 (list & lt; B & gt; entity); & Lt; R & gt; & Lt; R & gt; Example 2 (list increments unit); }
Comments
Post a Comment