Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d6477d5

Browse files
authored
Update 00_The_Collection_Interface.md
1 parent aa7b8d4 commit d6477d5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎ch12/00_The_Collection_Interface.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ boolean retainAll(Collection<?> c) // remove the elements *not* in c
3737
**查询集合的内容**
3838

3939
```java
40-
boolean contains(Object o) // 如果o存在,则为true
40+
boolean contains(Object o) // 如果o存在,则为true
4141
boolean containsAll(Collection<?> c) // 如果集合中存在c的所有元素,则返回 true
42-
boolean isEmpty() // 如果没有元素存在,则返回 true
43-
int size() // 返回元素数量(如果小于则返回 Integer.MAX_VALUE)
42+
boolean isEmpty() // 如果没有元素存在,则返回 true
43+
int size() // 返回元素数量(如果小于则返回 Integer.MAX_VALUE)
4444
```
4545

4646
对于超大型集合,大小返回 `Integer.MAX_VALUE` 的决定很可能是基于这样的假设,即具有超过 `20` 亿个元素的集合很少会出现。即便如此,一种提出异常而不是返
@@ -50,7 +50,7 @@ int size() // 返回元素数量(如果小于则返回 Integer.MAX_VALU
5050

5151
```java
5252
Iterator<E> iterator() // 在元素上返回一个迭代器
53-
Object[] toArray() // 将内容复制到 Object[]
53+
Object[] toArray() // 将内容复制到 Object[]
5454
<T> T[] toArray(T[] t) // 将内容复制到 T [](对于任何 T)
5555
```
5656

@@ -111,7 +111,8 @@ int[] a = l.toArray(new int[0]); // 编译错误
111111
```java
112112
List<Integer> l = Array.asList(0,1,2);
113113
int[] a = new int[l.size()];
114-
for (int i=0; i<l.size(); i++) a[i] = l.get(i);
114+
for (int i=0; i<l.size(); i++)
115+
a[i] = l.get(i);
115116
```
116117

117118
集合框架不包括将集合转换为基本类型数组的便利方法。 幸运的是,这只需要几行代码。

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /