private static void printNumbers(List<? extends Number> numbers) {
Number number = numbers.get(0);
}
or
List<String> names = new ArrayList<>();
List<?> tmp = names;
i learn the wildcard, use '?' symbol. and i learn this is also wildcard.
in my Thinking 'E' is not '?' symbol even though it works like upper bound wildcard. and if were E is wirdcard, how can i distingush between parametered type and wildcard type.
public class Cage<E extends Animal> {
private E animal1;
private E animal2;
public Cage() {
}
public Cage(E animal1, E animal2) {
this.animal1 = animal1; this.animal2 = animal2;
}
public E getAnimal1(){
return animal1;
}
public boolean isCompatible() {
return animal1.getType == animal2.getType;
}
}
public class Animal {
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
public class Monkey extends Animal {
}
public class Lion extends Animal {
}