What is the result of compilation and execution of the following program:
import java.util.*;
class Main {
public static void main(String[] args) {
List<?> list = new ArrayList<String>();
list.add("a");
System.out.println(list.get(0));
}
}
When you have an object of generic class defined with a wildcard <?>, you can't call methods, that take arguments of type-parameter. The only exception from this rule is passing the value null.
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати