Tuesday 15 May 2012

generics - compiler error converting java.util.list to java.util.list? -


I am just asking this question, but I can not understand what is happening to it

< Ex> import java.util.List; Public category listing replacement & lt; T & gt; {Private list & lt; T & gt; item; Personal paging paging; Public & lt; T & gt; ListResponse (list & lt; T & gt; items, paging paging) {this.items = ** item **; This.paging = paging; }}

I'm getting a compiler error on the item parameter that I marked. The error is:

  type mismatch: can not be changed with java.util.List  

Do you have any ideas that are happening? Thanks!

& lt; T & gt; defined as constructure-scope, class scocked & lt; T & gt; and the compiler behaves like these types of different types, this is the reason that you get a compile-time error.

Just get rid of the manufacturer's type parameter:

  Public List Response (list & lt; T & gt; items, paging paging) {This. Item = item; This.paging = paging; }  

No comments:

Post a Comment