java - How to set own model to an interface which get generic types parameters -


this interface ,

public interface onsendentitymessagelistener {     public <t> void onsendentity(class<t> entitytype, t message); } 

when want use interface below , build-in error

the method onsendentity(class, t) in type afragment.onsendentitymessagelistener not applicable arguments (class, string)

private void sendasamplemessagetoparent(account account) {       msendentity.onsendentity(account.class, "fragment message. : "+ account.getname());    } 

modal

public class account {     string name;      public string getname() {         return name;     }      public void setname(string name) {         name = name;     } } 

thanks helps

you have defined parameter message t in interface. t type argument in example bound type account when you're invoking

msendentity.onsendentity(account.class, "fragment message. : "+ account.getname()); 

you might have meant declare method

public <t> void onsendentity(class<t> entitytype, string message); 

instead.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -