java - Using wildcard with Lists.partition and nested generic types -


I am using, though I have thought that this is a general question about generic in Java.

I can do this:

  Public Zero to some (list & gt; DataBean & gt; ID) {list & lt; List & lt; DataBean & gt; & Gt; Lists = lists. Division (id, MAX_ITEMS);  

Why can not I do this?

  Public Nullification is an extension of some (list & lt;? Databane & gt; ID) {list & lt; List & lt;? Extension of Databen & gt; & Gt; Lists = lists. Division (id, MAX_ITEMS);  

I get the following compilation error:

  type mismatch: list & lt; List & lt; Can not convert from capture # 1? Extension of Databen & gt; & Gt; List & lt; List & lt;? Extension of Databen & gt; & Gt;  

You need to bind in such a way that it can be completed. Otherwise, ? List for ? is not related to id . You can declare a common method with a named parameter instead of the generic parameter with the wildcard:

  public & lt; T increases Databen & gt; Nothing to do (list & lt; T & gt; ID) {list & lt; List & lt; T & gt; & Gt; Lists = lists. Division (id, MAX_ITEMS); }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -