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:

  1. I want to be able to assign results to both A and B, to any super class.
  2. 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

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -