Wildcard
Wildcard ?
means everything. For wildcard we can just use without having to declare before return type like Type Parameter
public interface Authenticator<SomethingGeneric> {
SomethingGeneric get();
void remove(Authenticator<?> user);
<T extends SomethingGeneric> void connect(T user);
}
However the meaning in here is a bit different, since it's capturing everything, the logic does not necessary hold true for type safe
For example
public static <T extends Number> void copy(List<T> dest, List<T> src)
// vs
public static void copy(List<? extends Number> dest, List<? extends Number> src)
In here the first example guarantee that both dest
and src
will be of the same type whereas the second example does not.
Note: In some case it might be the same, for example
public <T extends Animal> void takeThing<ArrayList<T> list)
public void takeThing<ArrayList<? extends Animal> list)