java - Class Type casting compile error -


i have code, interestingly intellij complains @ make process (while running javac, not jit) when try run main:

public class foo {         public static void main(string[] args) {          resttemplate resttemplate = new resttemplate();          string restendpointurl = "";          integer userid = 0;           responseentity<? extends arraylist<foo>> responseentity =             resttemplate.getforentity(restendpointurl, (class<? extends arraylist<foo>>) arraylist.class, userid);       }    } 

in getforentity has signature:

public <t> responseentity<t> getforentity(string url, class<t> responsetype, object... urlvariables)

error:

error:(77, 94) java: inconvertible types   required: java.lang.class<? extends java.util.arraylist<foo>>   found:    java.lang.class<java.util.arraylist> 

java version: 1.7.0_60 in fact wanted ask not related intellij, it's java compilation. explain rules behind that?

code taken here.

i looked this answer not tell me of logic behind generics , typecasting works.

furthermore, should (or can) replace ? extends arraylist<foo> or ? super arraylist<foo> expressions arraylist<foo>, while trying solve kind of questions, exist in java certification exams? learning "why" me learning sort of approaches should take them.


Comments