Java generic interface with one parameter has actually two -


i found java code similar this:

public interface demointerface<t> extends serializable {     <v> void demomethod(collection<v> somevalues, sometype<v, t> morevalues); } 

since read advice on interfaces , never found situation ask here: interface statement mentions <t>. <v> mean?

if know answer please patient , give example how use interface , implementation of interface , demomethod.

thank you.

i offer example:

demointerface<type> demo = new demointerface<>() {  <v> void demomethod(collection<v> somevalues, sometype<v, type> morevalues) {   type type = new type();   foreach(v value: somevalues) {    type subtype = morevalues.dosomething(value);    type.concat(subtype);   }   system.out.printf("result: %s%n", type);   } };  sometype<valuea, type> somea = new sometype<>(); sometype<valueb, type> someb = new sometype<>(); list<valuea> lista = new arraylist<>(); // add elements list<valueb> lista = new arraylist<>(); // add elements  demo.demomethod(lista, somea);     demo.demomethod(listb, someb); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -