Passing Interface Class as a Parameter in Java
Posted
by aleclerc
on Stack Overflow
See other posts from Stack Overflow
or by aleclerc
Published on 2010-05-18T17:35:21Z
Indexed on
2010/05/18
17:50 UTC
Read the original article
Hit count: 317
I have an interface:
public interface IMech {
}
and a class that implements it
public class Email implements IMech {
}
and a third class that has this method implemented:
public void sendNotification( Class< IMech > mechanism ){
}
now I'm trying to call that method like so
foo.sendNotification(Email.class);
but i keep getting an exception saying:
The method sendNotification(Class<IMechanism>) in the type RemediationOperator is not applicable for the arguments (Class<EmailNotification>)
Shouldn't this work if it interfaces that class?
© Stack Overflow or respective owner