Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the rules for using java wildcards?

Shulou Source: shulou.com Published: 2022-05-31 10:52:59 10月03日 Update

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!

Tags: Wildcards rules variables applications programs learning applications keys keywords content system upper limit lower limit code even distributed instance object that is embedded Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft macOS Redmi Xiaomi