Why declare a variable as a wildcard type
问题 In the Java tutorials, it is sometimes written things like this : Set<?> unknownSet = new HashSet<String>(); While I understand the benefits of using type parameters and wildcards in class definitions and methods, I am wondering the following: What are the benefits of giving a variable a type that comprises a wildcard ? In real life, do people do that, and when ? 回答1: Wildcards are only really useful in method parameter declarations, as they increase the range of acceptable parameter types,