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 5020f02

Browse files
committed
fix format
1 parent 138f5bd commit 5020f02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎contents/create-arraylist-arraylistt-from-array-t.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
```java
66
Element[] array = {new Element(1),new Element(2),new Element(3)};
77
```
8-
如何将其转换为ArrayList<Element> arraylist呢?
8+
如何将其转换为ArrayList`<Element>` arraylist呢?
99

1010
###回答
1111
Arrays.asList(array)或者Arrays.asList(new Element(1),new Element(2),new Element(3))
12+
1213
不过,这样做有些坑要注意:
14+
1315
1. 这样做生成的list,是定长的。也就是说,如果你对它做add或者remove,都会抛UnsupportedOperationException。
1416
2. 如果修改数组的值,list中的对应值也会改变!
1517

0 commit comments

Comments
(0)

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