Explanation
1. The upper limit wildcard can be used to relax restrictions on variables.
For example, suppose you want to write a method that handles List, List and List, then you can achieve this by using upper bound wildcards.
2. The class instantiated by the upper bound wildcard must be the current class or a subclass of the current class.
3. If you want to declare an upper bound wildcard, please use a wildcard value.
Then comes the extends keyword, and finally its upper bound. Please note that in this context, extends is generally used to mean either extends (such as a class) or implements (such as an interface).
Example
public static void process(List extends Foo> list) { for (Foo elem : list) { // ... } }
Java is mainly used in:
1.web development;
2. Android development;
3. Client development;
4. Web development;
5. Enterprise application development;
6. Java big data development;
7. Game development, etc.
The above is the detailed content of How to use upper bound wildcard in java. For more information, please follow other related articles on the PHP Chinese website!