(Java) Collection 초기화
- www.baeldung.com/java-init-list-one-line
- www.baeldung.com/java-initialize-hashmap
- www.baeldung.com/java-combine-multiple-collections
1
2
3
Arrays.asList(“a”, “b”, “c”);
String[] strs = {"a", "b", "c"};
자바의 immutable?
1
2
3
4
private static final Thing[] PRIVATE\_VALUES = { ... };
public static final List<Thing> VALUES =
Collections.unmodifiableList(Arrays.asList(PRIVATE\_VALUES));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
return
ImmutableMap
.
of(
key1
, value1
,
key2
, value2
)
;
ImmutableMap
.
<
String
,
String
>
builder
()
.
put
(
key1
, value1
)
.
put
(key2, value2
)
.
build
()
;
This post is licensed under CC BY 4.0 by the author.