Home >Java >javaTutorial >How to use wildcards in java method parameters
Explanation
1. Wildcard? super Fruit limits the lower bound of the generic to Fruit.
2. Generic
Example
Generic<Fruit> fruitGeneric2 = new Generic<>(); print2(fruitGeneric2); Generic<Food> foodGeneric2 = new Generic<>(); print2(foodGeneric2); // 错误使用 // Generic<Apple> appleGeneric2 = new Generic<>(); // print2(appleGeneric2);
The above is the detailed content of How to use wildcards in java method parameters. For more information, please follow other related articles on the PHP Chinese website!