this is a piece of code i'm struggling with.
public class Channel<T extends Something>{ public Channel(){} public void method(T something){} } public class Manager{ private static ArrayList<Channel<? extends Something>> channels = new ArrayList<Channel<? extends Something>>(); public static <T extends Something> void OtherMethod(T foo){ for(Channel<? extends Something> c : channels) c.method(foo); // this does not work } } The line that does not work gives me compiler error:
The method method(capture#1-of ? extends Something) in the type Channel<capture#1-of ? extends Something> is not applicable for the arguments (T) I don't understand this error. If I remove all the generics in Manager class it is working but type unsafe. How should I do this in correct Java?