generics error: not applicable for the arguments
Can someone explain to me why the following code does not work? public class Test { interface Strategy<T> { void execute(T t); } public static class DefaultStrategy<T> implements Strategy<T> { @Override public void execute(T t) {} } public static class Client { private Strategy<?> a; public void setStrategy(Strategy<?> a) { this.a = a; } private void run() { a.execute("hello world"); } } public static void main(String[] args) { Client client = new Client(); client.setStrategy(new DefaultStrategy<String>()); client.run(); } } I'm getting the following error: The method execute(capture#3-of ?)