What are the rules for using java wildcards?
This article mainly explains "what are the rules for the use of java wildcards". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the rules for the use of Java wildcards"?
Description
1. Define in variables, using upper-bound wildcards.
Use the extends keyword.
2. Use the super keyword to define the out variable with the lower wildcard.
3. If the In variable can be accessed using the methods defined in the Object class, use unbounded wildcards.
4. Do not use wildcards when your code needs to access In and out variables.
Example
/ / Natural number class NaturalNumber {private int i; public NaturalNumber (int I) {this.i = I;} / /...} / even class EvenNumber extends NaturalNumber {public EvenNumber (int I) {super (I);} /...} what is Java an object-oriented programming language that can write desktop applications, Web applications, distributed systems and embedded system applications.
Thank you for your reading, these are the contents of "what are the rules for the use of java wildcards". After the study of this article, I believe you have a deeper understanding of what the rules for the use of java wildcards are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!