Files
Java-Basic-and-Advanced/泛型.md
2026-01-07 16:14:38 +08:00

33 lines
974 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 泛型
介绍:
JDK5版本后引入用处为编译阶段约束数据类型并例行检查。
好处:
统一了数据类型,将运行期的错误提到了编译期。
注意:
泛型只能用引用数据类型
## 泛型类
<img src="https://gitee.com/icecat2233/picture/raw/master/20250428164803021.png" alt="image-20250428164753200" style="zoom:80%;" />
## 泛型方法
<img src="https://gitee.com/icecat2233/picture/raw/master/20250428164850644.png" alt="image-20250428164848721" style="zoom:67%;" />
## 泛型接口
<img src="https://gitee.com/icecat2233/picture/raw/master/20250428165135118.png" alt="image-20250428165133488" style="zoom: 67%;" />
## 泛型通配符
<img src="https://gitee.com/icecat2233/picture/raw/master/20250428165220144.png" alt="image-20250428165218560" style="zoom:67%;" />
## 总结
<img src="https://gitee.com/icecat2233/picture/raw/master/20250428165312329.png" alt="image-20250428165310376" style="zoom: 60%;" />