Skip to content

Commit 01ad436

Browse files
authored
Merge pull request lingcoder#262 from LingCoder/sjsdfg-patch-1
Update 12-Collections.md
2 parents 6eb51c3 + 7d962ae commit 01ad436

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/book/12-Collections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ndOrangesWithoutGenerics.java:23)
6868

6969
在运行时,当尝试将 **Orange** 对象转为 **Apple** 时,会出现输出中显示的错误。
7070

71-
[泛型]()章节中,你将了解到使用 Java 泛型来创建类可能很复杂。但是,使用预先定义的泛型类却相当简单。例如,要定义一个用于保存 **Apple** 对象的 **ArrayList** ,只需要使用 **ArrayList<Apple>** 来代替 **ArrayList** 。尖括号括起来的是*类型参数*(可能会有多个),它指定了这个集合实例可以保存的类型。
71+
[泛型]()章节中,你将了解到使用 Java 泛型来创建类可能很复杂。但是,使用预先定义的泛型类却相当简单。例如,要定义一个用于保存 **Apple** 对象的 **ArrayList** ,只需要使用 **ArrayList\<Apple\>** 来代替 **ArrayList** 。尖括号括起来的是*类型参数*(可能会有多个),它指定了这个集合实例可以保存的类型。
7272

7373
通过使用泛型,就可以在编译期防止将错误类型的对象放置到集合中。[^3]下面还是这个示例,但是使用了泛型:
7474
```java

0 commit comments

Comments
 (0)