[Java] Collection 초기화
- www.baeldung.com/java-init-list-one-line
- www.baeldung.com/java-initialize-hashmap
- www.baeldung.com/java-combine-multiple-collections
```java
Arrays.asList(“a”, “b”, “c”);
String[] strs = {"a", "b", "c"};
```
자바의 immutable?
```java
private static final Thing[] PRIVATE_VALUES = { ... };
public static final List<Thing> VALUES =
Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES));
```
```java
return ImmutableMap.of(
key1, value1,
key2, value2);
ImmutableMap.<String, String>builder()
.put(key1, value1)
.put(key2, value2)
.build();
```
'Java Stack > Java' 카테고리의 다른 글
[Java] Jackson 프로퍼티명 snake_case <-> camelCase 변환 (0) | 2021.08.01 |
---|---|
[Java] HmacUtils, Mac이 thread-safe하지 않다? (0) | 2021.03.17 |
[Java] Enum to Json / Enum to Object (0) | 2020.04.27 |
[Spring] resources 경로 문제 (0) | 2020.03.18 |
[Effective Java] 12장 직렬화 (0) | 2020.02.28 |