Object o; o = "I am a String";
incompatible types: List<String> cannot be converted to List<Object>.
List<Object> objects;
List<String> strings = new ArrayList<>();
objects = strings;
List<Object> objects;
List<String> strings = new ArrayList<>();
objects = strings;
objects.add(10);
public void printList(List<Object> list) { for (Object o: list) prn(o.toString()); } public void caller() { List<String> names = Arrays.asList("A", "B", "C", "D"); printList(names); }
public void printList(List<? extends Object> list) {
for (Object o: list)
prn(o.toString());
}
public void caller() {
List<String> names =
Arrays.asList("A", "B", "C", "D");
printList(names);
}
//in superclass public Object foo() { //... //in subclass public String foo() //...
Comparator<? super T>